Home Forums WinForms controls Xceed Grid for WinForms Handling double click event for a Xceed.Grid.DetailGrid

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15577 |

    The Xceed.Grid.DetailGrid does not contain a double click or even a mouse click event that I can handle. The Xceed.Grid.GridControl does but not the before mentioned class. I am progreaming in Microsoft Visual Studio 2005 Version 8.0.50727.42, Microsoft Visual Basic 2005 with .NET Framework 2.0.50727 and Xceed Grid for .NET 3.0.

    Any help appreciated.

    Imported from legacy forums. Posted by EWerner (had 3037 views)

    Xceed Support
    Member
    Post count: 5658

    You need to subscribe on the “Click” or the “Double-Click” event on the cell itself. Here is a snippet of code that illustrate this procedure:

    e.g.,
    <code>
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    For Each cell As Cell In dataRowTemplate1.Cells
    AddHandler cell.DoubleClick, AddressOf cell_DoubleClick
    Next
    For Each cell As Cell In dataRowTemplate2.Cells
    AddHandler cell.DoubleClick, AddressOf cell_DoubleClick
    Next

    ‘Fill the grid with the DataSet
    ‘My grid is filled a master and a detail grid.
    End Sub

    ‘The “Double-Click” will have the same result for the master and the detail grid.
    Private Sub cell_DoubleClick(ByVal sender As Object, ByVal e As EventArgs)
    ‘Changing the Back Color of the Cell to Orange
    DirectCast(sender, Cell).BackColor = Color.Orange
    End Sub
    </code>

    Imported from legacy forums. Posted by CharlesB (had 785 views)

    User (Old forums)
    Member
    Post count: 23064

    A follow up that I have regarding Detail grids: How do I get the current row of the detail grid and then extract a specific value (like userID) from a column I have?

    For instance, at the Master level I can write
    userID = grdUsers.DataRows[currentRow].Cells(“colUserID”).Value

    And I track “currentRow” with the master grid’s CurrentRowChanged event. How can I do this same “currentRow” tracking with a detail grid?

    I’ve already wired up a pseudo-double click event to each cell in the detail grid but I can’t figure out how to interpret the Detail grid’s current row.

    Thanks.

    Imported from legacy forums. Posted by Jason (had 401 views)

    Xceed Support
    Member
    Post count: 5658

    The “gridControl1.CurrentRow” can be a reference to a Master Grid’s row as well as a Detail Grid’s row. It does not matter whether it is a Master Grid’s row or a Detail Grid’s row.

    You can directly reference it:

    <code>
    gridControl1.CurrentRow.BackColor = Color.Red
    </code>

    Or cast it as a Xceed.Grid.DataRow and get the value of a Cell:

    <code>
    Private strValue As String = DirectCast(gridControl1.CurrentRow, Xceed.Grid.DataRow).Cells(0).Value.ToString()
    </code>

    Imported from legacy forums. Posted by CharlesB (had 4036 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.