DatagridView Select last row

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

    Your 'catch' block for IndexOutOfRangeException is empty, and will not display any error at all.

    Either your question is not exact, or the exception is being thrown somewhere else.

    EDIT: Having looked through your call stack that you added, I can see that the error is, indeed, not being thrown here, but rather in the CurrencyManager class's Current/Item properties, which is ultimately being triggered by the call to the CurrentCell setter.

    Bottom line: the problem is not in this code; the exception is being thrown by some other piece of code triggered by your setting the current cell.

提交回复
热议问题