Hi all,
I have create a UserControl. There is a DataGridView in this UserControl.
I successfully drag this UserControl into my Windows Form Application.
If user double click on selected cell in datagridview, I want to show it on my textbox in my windows form.
But, how do I Catch DataGridView Double Click event in this user control

DataGridView Component
aymenos07
Sayan Ghosh
To catch the DataGridView Double Click event, double click on the DataGridView in the Form Designer, and an event-handler function will be auto-added to the Form code. Change the event at the end of the event function declaration to catch a double-click instead of a single mouse click.
Yun
Active_Matrix
What I use is DataGridView Double Click Event, then use SelectedRows.Count to get the particular selected row.
However, this DataGridView is in a user control and was compiled into Dll; when you add this user control to the form, I can't find the way to get the selectedrows.
Think it logical way, user double click on a row on datagrid & display it in form format to allow user modification.
Fredvanherz
You're right.. You can't use something you don't have access to. So you will have to code the DLL in order to leave access to control properties and manipulate whatever data with special routines.
LuvWhiteSand
I assume your refering to datagrid control right If so, Ive used Mouse Up event, define a point, check if the point.type its a cell and do what eer you cant with the data using point.row.
The only thing, its that instead of a double click, this validates just one mouse click. But it worked like a charm for me.
Happy coding,
JP
Frank Cassata
Ah, you didn't say that
.
If the usercontrol doesn't expose that functionality, then you can't use it: you will have to change the usercontrol to expose the doubleclick event (or expose the underlying DataGridView events) if that is what you are after. Additionally, you will need to expose more of the DataGridView properties in that control to get the elected rows. If the selected row count is important, then perhaps the usercontrol would have a SelectedRows property.
The whole point of the UserControl is to expose the functionality the user of the usercontrol needs (generally), and not necessarily expose all the contained controls functionality.
lnielsen
There should be a CellDoubleClick event. There are many other events with the DataGridView, maybe one of the others is what you need
If the question you are asking is how to pass the event to the form, then you could raise an event (defined for your user control) in that DataGridView event.