DatagridView Select last row

后端 未结 8 2009
你的背包
你的背包 2021-02-14 17:20

I have some trouble with setting the last row in my datagridview selected. I select the last row this way:

if (grid.Rows.Count > 0)
{
    try
    {
        gr         


        
8条回答
  •  孤街浪徒
    2021-02-14 17:49

    Have you thought about using Linq for this?

        grid.Rows.OfType().Last().Selected = true;
        grid.CurrentCell = grid.Rows.OfType().Last().Cells.OfType().First(); // if first wanted
    

提交回复
热议问题