Home Forums WinForms controls Xceed Grid for WinForms Getting values from a selected detail grids row?

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

    Hello,

    I have grid that displays a list of companies, and a detail grid that displays any contacts within those companies. What I would like to do is have a double click event on my detail grid that will display more information about that contact. So pretty much all I need to do is get access to the primary key value of the detail grid. But it appears that the only value member property is for the entire grid only? How can I determine values from a selected detail grids row?

    ACanadian

    Imported from legacy forums. Posted by ACanadian (had 5349 views)

    Xceed Support
    Member
    Post count: 5658

    Hi ACanadian,

    When dealing with mouse and keyboard events, once there are rows in the grid, if these rows contain cells, it is the cells that will raise the mouse and keyboard events. If the row does not have cells, then it is the row that will raise the events. With the mouse and keyboard events, it is easier to think of the grid as a Panel containing “child” rows which in turn contain “child” cells.

    Have a look at the following KB article http://www.xceedsoft.com/kb/result.asp?id=311
    it demonstrates how to handle the click event for each cell in the main grid. In your case, you will need to do it for the detail grids that you want rather than the main grid.

    The sender in the click event will be the cell. To get the row that was clicked (the cell’s parent row), you can the verify the cell’s ParentRow property.

    I hope this helps!

    Imported from legacy forums. Posted by Jenny [Xceed] (had 699 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks,

    That was exaclty the answer I was looking for.

    //Change the sender object into a cell
    Xceed.Grid.Cell c = (Xceed.Grid.Cell)sender;

    //Get the value from the cells parent row
    int nContactId = (int)c.ParentRow.Cells[“ContactId”].Value;

    Thanks for the quick overview of how the grids click events work.

    ACanadian

    Imported from legacy forums. Posted by ACanadian (had 3496 views)

    User (Old forums)
    Member
    Post count: 23064

    I tried to look in the KB u were referring, but that was not there.

    What I need to do is this.

    I have a grid, grouping is enabled. I need to get column[2] value after selecting a particular row.

     Please tell me how to do this.

     – Regards

    – Buddhi –

    Imported from legacy forums. Posted by bdmsoft (had 252 views)

    User (Old forums)
    Member
    Post count: 23064

    Please specify what is the exact event what I have to use, and if possible please post a small sample too.

     

    – Buddhi –

    Imported from legacy forums. Posted by bdmsoft (had 298 views)

    User (Old forums)
    Member
    Post count: 23064

    You can subscribe to the CurrentRowChanged or CurrentCellChanged event, and get the value from the needed cell.

    Here is an example using the CurrentRowChanged event :

        private void Form1_Load( object sender, EventArgs e )
        {    
          gridControl1.CurrentRowChanged += new EventHandler( gridControl1_CurrentRowChanged );
        }

        void gridControl1_CurrentRowChanged( object sender, EventArgs e )
        {
          Xceed.Grid.DataRow row = gridControl1.CurrentRow as Xceed.Grid.DataRow;
          string value = row.Cells[ 2 ].Value as string;
        }
     

     

    Imported from legacy forums. Posted by André (had 3442 views)

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