Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在WinC中更改GridView中的行选择器#_C#_.net_Winforms - Fatal编程技术网

C# 如何在WinC中更改GridView中的行选择器#

C# 如何在WinC中更改GridView中的行选择器#,c#,.net,winforms,C#,.net,Winforms,我在C#Net2010中有windows应用程序。。我添加了griview,其中包含一些ComboBox和CheckBox列 我在GridView中为一些数据相关问题设置了一些只读行 现在,当事件用户从combobox列中选择一些值并按enter键时,如果下一行是只读的,我想将rowSelector设置为非只读的行 我编写了以下代码: for (int i = gridAttendanceEntry.CurrentRow.Index + 1; i < gridAttendanceEntr

我在C#Net2010中有windows应用程序。。我添加了griview,其中包含一些ComboBox和CheckBox列

我在GridView中为一些数据相关问题设置了一些只读行

现在,当事件用户从combobox列中选择一些值并按enter键时,如果下一行是只读的,我想将rowSelector设置为非只读的行

我编写了以下代码:

 for (int i = gridAttendanceEntry.CurrentRow.Index + 1; i < gridAttendanceEntry.Rows.Count; i++)
             {
                 if (!gridAttendanceEntry.Rows[i].ReadOnly)
                 {
                     gridAttendanceEntry.Rows[i].Selected = true;
                     this.gridAttendanceEntry.FirstDisplayedScrollingRowIndex = i;
                     break;
                 }
                 if (i == gridAttendanceEntry.Rows.Count - 1)
                     i = 0;
             }
for(int i=gridAttendanceEntry.CurrentRow.Index+1;i
如何以编程方式更改行选择器

  • 获取选定/聚焦的行索引
  • 将其临时保存为整数变量并执行+1操作
  • 检查具有新索引的行是否为只读。不选择它,否则添加1并再次执行步骤3

  • 你需要这个else语句。我相信控件的默认行为是在组合框中进行更改后选择下一行。在您的情况下,当该行为只读时,您需要通过手动取消选择来确保没有发生这种情况。

    我的操作与您指定的完全相同:但我编写了代码:GridView.rows[i]。selected=true;但RowSelector仍然会转到下一行,该行是只读的:在哪种情况下编写此代码?在选择更改或更改事件中?可能是另一个事件覆盖了此代码
    if (!gridAttendanceEntry.Rows[i].ReadOnly) 
    { 
         gridAttendanceEntry.Rows[i].Selected = true; 
         this.gridAttendanceEntry.FirstDisplayedScrollingRowIndex = i; 
         break; 
    }
    else
    {
         gridAttendanceEntry.Rows[i].Selected = false;
    }