|
-
October 17th, 2005, 01:15 PM
#1
How To: Invoke an event.
How can I Invoke a particular event programatically? Lets say a double click event on datagrid?
-
October 17th, 2005, 01:17 PM
#2
Re: How To: Invoke an event.
good ol win32 api. its a little more involved than you might think.
-
October 17th, 2005, 03:12 PM
#3
Re: How To: Invoke an event.
Invoking such events looks like really bad design. In most cases this can be avoided by calling a function.
If you really need to, you could derive from DataGrid, and invoke the DoubleClick event, but you will need to create a MouseEventArgs with some coordinates (The real ones can be extracted from Cursor class).
-
October 17th, 2005, 03:30 PM
#4
Re: How To: Invoke an event.
 Originally Posted by jhammer
Invoking such events looks like really bad design.
I 100% agree with that.
you can add the event handler for that action, then call the event handler. its not invoking that event, you using what happens when that event is triggered w/ out clicking away.
-
October 18th, 2005, 11:59 AM
#5
Re: How To: Invoke an event.
Thanks a lot for your replies.
Could you give a code example as to how to do it? Thanks.
-
October 18th, 2005, 12:37 PM
#6
Re: How To: Invoke an event.
Please tell us exactly what you want to do.
-
October 18th, 2005, 03:29 PM
#7
Re: How To: Invoke an event.
Here is what I was trying to do:
I was trying to autosize datagrid columns using the following:
Code:
Type t = dgTC.DataSource.GetType();
MethodInfo m = t.GetMethod("ColAutoResize", BindingFlags.Instance | BindingFlags.NonPublic);
for (int i = dgTC.FirstVisibleColumn; (i< dgTC.VisibleColumnCount); i++)
{
m.Invoke(dgTC, new object[]{i});
}
As far as my understanding goes, ColAutoResize is called whenever user double clicks on the splitter b/w two columns. But eversince I added custom columns I was getting excpetion. But when I would double click on the splitter it would still autosize it.... So, I was just trying to use the funcitonality that was used by datagrid when user would double click on the splitter.
Hope that would explain it, if I need to describe something more please let me know. Thanks in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|