Home › Forums › WinForms controls › Xceed Grid for WinForms › Double Click Event
-
AuthorPosts
-
#13136 |
How can I catch the double click on the row and its value?
Imported from legacy forums. Posted by PETE (had 6010 views)
If it’s a row without cells, you can catch the DoubleClick-event of the row itself. If it’s a row with cells (CellRow, ValueRow, DataRow, …), you have to catch the DoubleClick-event of the individual cells, like this:
<code>
foreach(Xceed.Grid.Cell cell in row.Cells) cell.DoubleClick += new EventHandler(CellDoubleClick);
private void CellDoubleClick(object sender, EventArgs e)
{
Xceed.Grid.CellRow row = (sender as Xceed.Grid.Cell).ParentRow;
}
</code>Imported from legacy forums. Posted by Tommy (had 326 views)
I am also having same problem. Following are the Tommy’s code which I converted to VB.NET:
Dim cell As Xceed.Grid.Cell
For Each cell In <u>Row.Cells</u>
cell.DoubleClick = New EventHandler(CellDoubleClick)
NextPrivate Sub CellDoubleClick(ByVal sender As Object, ByVal e As EventArgs)
Dim row As Xceed.Grid.CellRow = (sender)
‘as Xceed.Grid.Cell.ParentRow
End SubThere is a problem in the underlined code. how can I refer the cells here?
Imported from legacy forums. Posted by DOS (had 307 views)
I don’t understand the problem. Perhaps VB.NET has problems with indexers, collections and foreach.
Here is the code in VB.NET (untested):‘ row is the Xceed.Grid.CellRow you want to detect double-clicks from
Dim cell As Xceed.Grid.Cell
Dim i As Integer
For i = 0 To row.Cells.Count – 1
AddHandler row.Cells.Item(i).DoubleClick, AddressOf CellDoubleClick
NextPrivate Sub CellDoubleClick(ByVal sender As Object, ByVal e As EventArgs)
Dim cell As Xceed.Grid.Cell
Dim row As Xceed.Grid.CellRow
cell = CType(sender, Xceed.Grid.Cell)
row = CType(cell.ParentRow, Xceed.Grid.Row)
End SubImported from legacy forums. Posted by Tommy (had 339 views)
Still I could not access the ‘row’
i get error here:
For i = 0 To <u>row.Cells.</u>Count – 1
Imported from legacy forums. Posted by DOS (had 248 views)
row is just an example, it’s not an existing property. It should be defined as an Xceed.Grid.CellRow (including DataRow and ValueRow).
Imported from legacy forums. Posted by Tommy (had 209 views)
Stilll trying to access the row & cell object….
myGrid.BeginInit()
Dim row As Xceed.Grid.CellRow = myGrid.CurrentRow
MsgBox(row.Cells.Count)
myGrid.EndInit()following error occured with the above code:
Ojbect reference not set to an instance of an object.
if i could solve this problem, i may be able to workaround the cells.
Imported from legacy forums. Posted by DOS (had 273 views)
Before trying to get the Cells-property, check if row is not Nothing (null in C#).
Imported from legacy forums. Posted by Tommy (had 267 views)
I found the answer at last.
‘adding event handler in form load
Dim cell As DataCell
For Each cell In mygrid.DataRowTemplate.Cells
AddHandler cell.DoubleClick, AddressOf Me.Cel_DoubleClick
Next cellPrivate Sub Cel_DoubleClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mygrid.DoubleClick
Dim cell As Cell = CType(sender, Cell)‘parentRow’s property can be used to access the rows value
Dim parentRow As CellRow = cell.ParentRow
End SubImported from legacy forums. Posted by PETE (had 6804 views)
-
AuthorPosts
- You must be logged in to reply to this topic.