DatagridView Select last row

后端 未结 8 2032
你的背包
你的背包 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:31

    Eventually the last row is empty because it's the empty row with which the user can add a new row. This row cannot be selected. Have you tried grid.Rows.Count - 2? As an alternative, you can set AllowUserToAddRows to false.

提交回复
热议问题