HDokes Posted June 28, 2003 Posted June 28, 2003 Hello, I am using a datagrid on a database form in VB from which I would like to be able to establish and perform a piece of code upon a double click within the cell. My dilema is that while in the 'edit' mode of the form, when I double click on a any cell in the datagrid, the entire datagrid is selected and takes me to the following: Private Sub grdButton_Assignment_Table_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles grdButton_Assignment_Table.Navigate End Sub I can find no reference in the MSDN libraries that would show how one could 'trap' on a 'double click' within a cell and add code to that 'trap'. If I can not 'trap' on a 'double click' then I could otherwise allow the user to 'select' a file through a button trap (which I have tried) however I can find no method for pushing the subsequent string of data into the last selected cell in the datagrid. Any ideas? Quote Thanks for any assistance provided and take care, Hdokes
Moderators Robby Posted June 28, 2003 Moderators Posted June 28, 2003 The thing about Click and DoubleClick events is that they are at the Datagrid level and not the Cell level. You can use the CurrentCellChanged event to pinpoint which Cell the user clicks on. Quote Visit...Bassic Software
Heiko Posted June 28, 2003 Posted June 28, 2003 Or, with a lot of hassle, you could use the MouseDown event of the DataGrid, because the mousedown eventargs contain the X,Y coordinates. This would make it possible for you to compute, which cell the cursor is actually over right now. Quote .nerd
Moderators Robby Posted June 28, 2003 Moderators Posted June 28, 2003 Heiko, why go to all that hassle when you can simply get the exact cell clicked using CurrentCellChanged. Either way we're not getting the Double-click. 'This gets the column and row... Datagrid1.CurrentCell.ColumnNumber Datagrid1.CurrentCell.RowNumber 'or if you wanted to know the column name so as to perform a query based on the Dataset... Dataset1.Tables(0).Columns(Datagrid1.CurrentCell.ColumnNumber).ColumnName.ToString Quote Visit...Bassic Software
Heiko Posted June 28, 2003 Posted June 28, 2003 Probably because just the other day I programmed a "mouse down" on status bar panels .... :) oh my Quote .nerd
HDokes Posted June 29, 2003 Author Posted June 29, 2003 Greetings again, Thanks Robby for the info. This at least allows me to 'push' a text string into the last cell selected which in the end is what I wanted to achieve. Seems a bit odd however that there are no immediate mouse events that can be captured when clicking inside the datagrid. This would have made the process I am working on more seemless and would have eliminated a couple a step that the user is forced to initiate... i.e.... click on a button after selecting the cell. I used the following line to 'fill' the cell.... grdButton_Assignment_Table.Item(grdButton_Assignment_Table.CurrentCell.ColumnNumber, grdButton_Assignment_Table.CurrentCell.RowNumber) = openFileDialog1.FileName Quote Thanks for any assistance provided and take care, Hdokes
*Experts* jfackler Posted June 29, 2003 *Experts* Posted June 29, 2003 Have you looked here? http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q869q Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.