473,498 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delegates for Setting Control Properties

I am trying to set a property of a control from a thread started from the UI
thread using Delegates. I can set the property directly in the thread if I
set the form's CheckForIllegalCrossThreadCalls property to False. However, I
don't want to do that so I am trying to use Delegates and the control's
invoke method.

Any suggestions on how to do this?
--
Dennis in Houston
Sep 16 '07 #1
2 1165

hello Dennis

this should work

### simple example

Delegate Sub CrossThreadInvParaMC()

Public Sub Test()
If YourcontrolName.InvokeRequired Then
Dim d As New CrossThreadInvParaMC(AddressOf Test)
Me.Invoke(d, Nothing)
Else
'do whatever you want to do e.g.

YourcontrolName.Propname='blahblah'
End If
End Sub
######

this works fine here ( asynchronous delegates and seperate threads that
comunicate to 1 gui to to show whats happening to the user



"Dennis" <De****@discussions.microsoft.comschreef in bericht
news:6E**********************************@microsof t.com...
>I am trying to set a property of a control from a thread started from the
UI
thread using Delegates. I can set the property directly in the thread if
I
set the form's CheckForIllegalCrossThreadCalls property to False.
However, I
don't want to do that so I am trying to use Delegates and the control's
invoke method.

Any suggestions on how to do this?
--
Dennis in Houston

Sep 16 '07 #2
Worked great...thanks.
--
Dennis in Houston
"Michel Posseth [MCP]" wrote:
>
hello Dennis

this should work

### simple example

Delegate Sub CrossThreadInvParaMC()

Public Sub Test()
If YourcontrolName.InvokeRequired Then
Dim d As New CrossThreadInvParaMC(AddressOf Test)
Me.Invoke(d, Nothing)
Else
'do whatever you want to do e.g.

YourcontrolName.Propname='blahblah'
End If
End Sub
######

this works fine here ( asynchronous delegates and seperate threads that
comunicate to 1 gui to to show whats happening to the user



"Dennis" <De****@discussions.microsoft.comschreef in bericht
news:6E**********************************@microsof t.com...
I am trying to set a property of a control from a thread started from the
UI
thread using Delegates. I can set the property directly in the thread if
I
set the form's CheckForIllegalCrossThreadCalls property to False.
However, I
don't want to do that so I am trying to use Delegates and the control's
invoke method.

Any suggestions on how to do this?
--
Dennis in Houston


Sep 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
18295
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
0
1178
by: Billy | last post by:
I have a web page with a control (Control#A) on it. The control (#A) has a control (Control#B) on it which displays an exception message when set and displayed. I am creating a simple datagrid...
6
1670
by: Angel | last post by:
I have a button, combo, and custom control that i created. When I click the button i want to set certain display properties of my custom control depending whats in the combo. I set those properties...
8
2249
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing...
30
3606
by: Burkhard | last post by:
Hi, I am new to C# (with long year experience in C++) and I am a bit confused by the language construct of events. What is it I can do with events that I cannot do with delegates? At the moment...
6
1399
by: PJ6 | last post by:
I would like to refer to properties in code without having to resort to using a string for the name. AddessOf gives me this ability for methods, but I can't find a single way to point that at the...
6
11055
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
2
3251
by: studio60podcast | last post by:
I'm not sure I can do this, but here is what I'm trying to accomplish... I have a WebUserControl that has a single control - a DropDownList - called BoundDL. In that control, I have methods...
9
3090
by: raylopez99 | last post by:
Hello all— I’m trying to get the below to work and cannot get the format right. It’s from this example: http://msdn.microsoft.com/en-us/library/8627sbea(VS.71).aspx What it is: I’m trying...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7203
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.