Home Forums WinForms controls Xceed Grid for WinForms Selecting Row in grid on double-click

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

    Hi all,

    We’re using the grid as a search/lookup tool, and need to give the user the ability to double-click a row and have the row be selected as input into the parent form.

    we’re trying to use:
    gridPatientSearch.SelectedRows(0)

    but it isn’t working, all other uses of the grid seem to point at manipulating data in the grid, not selecting a row for use elsewhere.

    any help would be greatly appreciated.

    Thanks,

    -Gregg

    Imported from legacy forums. Posted by ghartt (had 4159 views)

    User (Old forums)
    Member
    Post count: 23064

    1. Registering for the double-click event:

    – capture the AddingRow-event (I think it’s AddingRow…) of the grid
    – in the row-addition method, capture the DoubleClick-event of the added row

    2. Retrieve the double-clicked row:

    – in the double-click method, I think the <i>sender</i>-parameter is the row that was double-clicked (haven’t tried yet).
    – if <i>sender</i> is not the row, just use the grid.CurrentRow, which should be the row that was double-clicked.

    Imported from legacy forums. Posted by Tommy (had 309 views)

    User (Old forums)
    Member
    Post count: 23064

    I just realized I made a mistake: in 1, you have to capture the DoubleClick-event of <b>each cell</b> of the added row (for-loop over <b>Cells</b>-property). In 2, the <i>sender</i>-parameter is the cell that was double-clicked: just cast it to a <b>Cell</b>, and get the <b>ParentRow</b>-property to get the row. Sorry for the mistake.

    Imported from legacy forums. Posted by Tommy (had 229 views)

    User (Old forums)
    Member
    Post count: 23064

    an example would be alot better

    Imported from legacy forums. Posted by narf03 (had 404 views)

    User (Old forums)
    Member
    Post count: 23064

    Here’s an (untested) example, in C#:<code>EventHandler handler = new EventHandler(myGrid_CellDoubleClick);
    foreach(Cell cell in myGrid.DataRowTemplate.Cells)
    cell.DoubleClick += handler;
    private void myGrid_CellDoubleClick(object sender, EventArgs e)
    {
    Cell cell = sender as Cell;
    DataRow row = cell.ParentRow as DataRow;
    }</code>

    Imported from legacy forums. Posted by Tommy (had 4862 views)

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