User (Old forums)MemberMarch 9, 2005 at 12:18 pmPost count: 23064
I am trying to change the row color upon double click. Grid will be populated upon selected in the combo box. Nothing happends when I doulecllick on the the grid unless i select the combo twice (populating the grid twice). Seems to be the focus going somewhere out of the grid. Anyone here to help me?
Here’s the code:
private sub fillGrid
grdMenus.DataSource = menusDS.Tables(“menus”)
Dim cell As DataCell
For Each cell In grdMenus.DataRowTemplate.Cells
AddHandler cell.DoubleClick, AddressOf selectMenus
Private Sub selectMenus(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim row As CellRow = grdMenus.CurrentRow
If row.ForeColor= Color.Red Then
row.ForeColor = Color.Red
Catch ex As Exception
Imported from legacy forums. Posted by PETE (had 868 views)User (Old forums)MemberMarch 9, 2005 at 1:15 pmPost count: 23064
Whenever ‘double click’ event occured, selectMenus sub being accessed more than 10 times. where am i doing the mistake?
Imported from legacy forums. Posted by PETE (had 274 views)User (Old forums)MemberMarch 9, 2005 at 1:16 pmPost count: 23064
I see you use a Try…Catch-block, and just ignore the exception. Maybe you should put a breakpoint in the Catch-block, and see if an exception occurs.
I also see you use grdMenus.CurrentRow to find out what row was double-clicked. This might not always be accurate. I think it’s better to cast the sender-argument to Cell, and get the ParentRow of that cell, like this:<code>Dim cell As Cell = sender
Dim row As CellRow = cell.ParentRow</code>
PS: You should only add the double-click event once, not each time you populate the grid.
Imported from legacy forums. Posted by Tommy (had 245 views)User (Old forums)MemberMarch 10, 2005 at 6:54 amPost count: 23064
Thank you Tommy. You are always there for this forum.
As you answered, I did two things to make it work.
1. instead of grid.currentRow, I used cell as the sender argument
2. I put the double-click event at form_load
Imported from legacy forums. Posted by PETE (had 3789 views)
- You must be logged in to reply to this topic.