Selecting a row in DataGridView programmatically

后端 未结 8 2375
被撕碎了的回忆
被撕碎了的回忆 2020-12-08 12:58

How can I select a particular range of rows in a DataGridView programmatically at runtime?

8条回答
  •  情话喂你
    2020-12-08 13:15

     .ClearSelection(); ----------------------------------------------------1
     foreach(var item in itemList) -------------------------------------------------------2
     {
        rowHandle =.LocateByValue("UniqueProperty_Name", item.unique_id );--3
        if (rowHandle != GridControl.InvalidRowHandle)------------------------------------4
        {
            .SelectRow(rowHandle);------------------------------------ -----5
        }
      }
    
    1. Clear all previous selection.
    2. Loop through rows needed to be selected in your grid.
    3. Get their row handles from grid (Note here grid is already updated with new rows)
    4. Checking if the row handle is valid or not.
    5. When valid row handle then select it.

    Where itemList is list of rows to be selected in the grid view.

提交回复
热议问题