|
Why use Invoke? Just read the control like usual..
private void btnReadControlThread_Click(object sender, EventArgs e)
{
Thread thread = new Thread(ThreadReadControl);
thread.Start();
}
private void ThreadReadControl()
{
MessageBox.Show("Enable status is " + cbEnableStatus.Checked.ToString());
}
8.Kelvin()
{
while (!(the machine can program itself))
Wont_stop_coding = true;
}
|
|
|
|
|
Many thanks. Typical! me trying to overcomplicate things again. Cheers Bruce
|
|
|
|
|
Not sure about the safety of reading properties directly across threads as opposed to calling methods etc...
I suppose you could provide a GetEnabled (and if needed SetEnabled) method that use the property's getter (and setter) and call Invoke on that.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I try following code;
WebClient wClient = new WebClient();
wClient.DownloadFile("http://www.google.com", "C:\\google.html");
But those code do not download resource file (like css, image...). How can I download COMPLETE web page using with C#.NET
Best Regards...
|
|
|
|
|
Download the html page, use regular expressions or something similar to find references to images or css on the html,and download them as well...
|
|
|
|
|
Its really hard way.
I download http://www.google.com/
And I read source, find <img src=images/hp0.gif width=158 height=78 alt="Google">
Than I download http://www.google.com/images/hp0.gif
|
|
|
|
|
Hi Guys. I have a slight problem. My application usses EarlyBinding.where I reference Excel 12. Problem I'm having is that most of the machines targeted have Excel 10 or Excel 11 installed so when installing the App or running it I get a GAC error. This I know is that the versions are not backward compatable. My question is, how do I go from earlybinding to LateBinding with as little changes possible. Below I instanciate my Excel Workbook etc. My code is doing loads of stuff and I wouldn't want to rewrite all of it.
Microsoft.Office.Interop.Excel.Application objExcel =
new Microsoft.Office.Interop.Excel.Application();
objExcel.Visible = false;
Microsoft.Office.Interop.Excel.Workbook objBook =
objExcel.Workbooks.Add(System.Reflection.Missing.Value);
Microsoft.Office.Interop.Excel.Worksheet objSheet =
(Microsoft.Office.Interop.Excel.Worksheet)
objBook.Worksheets.get_Item(1);
Microsoft.Office.Interop.Excel.Range objRange;
Any advice would be appreciated.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
You can do this using something like this:
object xl = Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application"));
object books = xl.GetType().InvokeMember(
"Workbooks", BindingFlags.GetProperty, null, xl, null);
object book = books.GetType().InvokeMember( "Add",
BindingFlags.InvokeMethod, null, books, null );
object sheets = book.GetType().InvokeMember( "Worksheets",
BindingFlags.GetProperty,null, book, null );
object[] parameters;
parameters = new object[1];
parameters[0] = 1;
object sheet = sheets.GetType().InvokeMember( "Item",
BindingFlags.GetProperty, null, sheets, parameters );
parameters = new object[2];
parameters[0] = "A1";
parameters[1] = Missing.Value;
object range = sheet.GetType().InvokeMember( "Range",
BindingFlags.GetProperty, null, sheet, parameters );
parameters = new object[1];
parameters[0] = "1";
range.GetType().InvokeMember( "Value",
BindingFlags.SetProperty, null, range, parameters );
parameters = new object[1];
parameters[0] = true;
xl.GetType().InvokeMember( "Visible",
BindingFlags.SetProperty, null, xl, parameters ); I've just knocked this together in Notepad, so I apologise if it's not 100% perfect.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Cool, looks good though. My concern is when I start writing the data, for example see below portion of code.
objSheet.Cells[iR, iC] = CLIENTSURNAME.Trim();
objSheet.Cells[iR, iC + 1] = CLIENTFORENAMES.Trim();
objSheet.Cells[iR, iC + 2] = TITLE.Trim();
objSheet.Cells[iR, iC + 3] = "'" + ADDRESSLINE1.Trim();
objSheet.Cells[iR, iC + 4] = "'" + ADDRESSLINE2.Trim();
objSheet.Cells[iR, iC + 5] = "'" + ADDRESSLINE3.Trim();
objSheet.Cells[iR, iC + 6] = "'" + ADDRESSLINE4.Trim();
objSheet.Cells[iR, iC + 7] = "'" + POSTALCODE.Trim();
objSheet.Cells[iR, iC + 8] = LEVEL;
would I need to do the same as your example above
Pete O'Hanlon wrote: // get the "range" A1.parameters = new object[2];parameters[0] = "A1";parameters[1] = Missing.Value;object range = sheet.GetType().InvokeMember( "Range", BindingFlags.GetProperty, null, sheet, parameters );
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Yup. It's not pretty. I'd write some helper methods to do this if I were you.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
Hi All,
Actually the problem is there is a task to be done "taking backup of message rules for an outlook profile".
How is it done:
- In outlook Open Tools.
- Select Rules and Alerts
- In Rules and Alerts dialog select "options"
- Click "Export Rules"
- This will create a .rwz file
So now i want to create this .rwz file programatically.
If any references, please post it..
Thanks in adv,
ashok
|
|
|
|
|
Hi,
I was using ms office 2003 in window application project to display information in word format now i have updated it, now i installed 2007.
Now word file not displaying some i don't know why.
Can any one tell me what will be the problem what should i do?
Please do replay.
Thanks
|
|
|
|
|
Did you used COM to communicate with office 2003??
|
|
|
|
|
|
If your problem is solved, please post the way by which you have solved....
It may be useful for someone else sometime.....
Have a Happy Coding.....
|
|
|
|
|
Hi to everyone,
I'm just trying to pass parameter to a JavaScript function from C# code.
The parameterless function is as shown in part1, but I want it to be parametric therefore, I made a bit changes as shown in part2:
--- part1 ---
function next(){
var pass = document.getElementById("ctl17_password");
if(window.event && window.event.keyCode == 13) {
pass.focus();
return false;
}
else
return true;
}
In C# I use the below code:
UserName.Attributes.Add("onkeypress", "return next()");
THIS WAY EVERYTHING IS OK.
-------------
--- part2 ---
function next(parameter) {
var pass = document.getElementById(parameter);
if (window.event && window.event.keyCode == 13) {
pass.focus();
return false;
}
else
return true;
}
In C# I use the below code:
UserName.Attributes.Add("onkeypress", "return next(ctl17_password)"); --- BUT THIS DOES NOT WORK, I'm not also sure about passing the "parameter" variable as: getElementById(parameter);
-------------
I made some search on this issue, but couldn't find exactly what I needed. Could you please help me?
Thank you very much
Regards,
codddy
|
|
|
|
|
This is an ASP.NET question, not one for the C# forum.
Anyway, the corect way to do this it to use:
UserName.Attributes.Add("onkeypress", string.Format("return next('{0}');", password.ClientID)); Never hardcode the control name of an ASP.NET control into JavaScript methods. If you move where this control is situated, the ID changes because ASP.NET mangles the ID to ensure uniqueness.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi Pete, thanks a lot for your answer.
Yes, I was aware that hardcoding was wrong, but because of some urgent reasons I had to do it. Thanks again.
I would like to ask one more question.
I used your way and everything works fine locally. But on the server it does not even come to JavaScript function?
Do you have any idea about this issue?
Regards,
coddy
|
|
|
|
|
Hi,
In a form i have so many panels and controls
when i increase one panel it overrides another controls. scroll bars are not comming.
dock style is fixed at bottom.
|
|
|
|
|
hmm... interesting.
var question = (_2b || !(_2b));
|
|
|
|
|
In order to get some help you will have to describe your problem a little better.
Is this happening at run-time or design-time?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Its run time.
i set above controls panel's dock style is fill and
down panel's dock is bottom. (this is fixed for my requrement)...
|
|
|
|
|
In that case investigate 'Z order'.
If you are still stuck after reading up on that, post back and I will try to help.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi I am given with a project where advertisements are added in between serials. So for that we need to first split the video file into pieces and merge it with those advertisements. Can anyone help me out in this.
|
|
|
|