Infragistics UltraGrid:如何删除第一行的默认选择
我已将 UltraGrid 放在 WinForms 用户控件上。 我调整了一些设置,以便可以将网格用作只读多行选择表。 但有一个问题:默认情况下,第一行似乎被选中。
但 Selected.Rows
属性为空,ActiveRow
属性也为 null
。
因此,该行似乎已被选中,但实际上并未被选中,因此无法删除选择。
我确信 UltraGrid 上一定隐藏着一个设置来控制这种行为。 如果情况并非如此,那么也许有解决方法?
谢谢。
I have put an UltraGrid on a WinForms user control. I have tweaked some settings so I can use the grid as a read-only multi-row select table. But there's one problem: by default the first row appears to be selected.
But the Selected.Rows
property is empty, and also the ActiveRow
property is null
.
So the row appears to be selected, but it actually isn't, making it impossible to remove the selection.
I'm sure there must be a setting hidden somewhere on the UltraGrid to control this behavior.
And if this is not the case then maybe there's a workaround?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
经过一番研究,我找到了解决方案,我将与大家分享:
After some more research I have found a solution, which I'll share with all of you:
尝试这个:
try this:
这帮助我抑制网格的“活动外观”:
如果您也不希望将行标记为选定,则必须对“选定外观”执行相同的操作:
This helped me in suppressing the "Active Appearance" of a grid:
If you also don't want a row to be marked as selected, you have to do the same for "Selected Appearance":
我遇到了与您完全相同的问题,但 Gerrie Schenck 的解决方案对我不起作用。
我用了这个技巧:
MyUltraGrid.ActiveRow = MyUltraGrid.Rows[0];
MyUltraGrid.ActiveRow = null;
I have exactely the same problem you had, but Gerrie Schenck's solution don't work for me.
I used this trick:
MyUltraGrid.ActiveRow = MyUltraGrid.Rows[0];
MyUltraGrid.ActiveRow = null;
区分“选定”和“活动”很重要。 网格永远不会自动选择任何行。您所看到的是 ActiveRow,它会像所选行一样突出显示。
网格的 ActiveRow 与CurrencyManager 同步,因此默认情况下网格的第一行会突出显示。 重置 ActiveRowAppearance 和 ActiveCellAppearance 将从 ActiveRow 中删除默认突出显示。
但需要注意的是,这并不能阻止该行成为活动行,只是网格不再突出显示活动行。 由于该行仍然处于活动状态(并且无法阻止这种情况),任何突出显示活动行的其他内容仍然会突出显示该行。 例如,如果您将样式库 (*.isl) 文件加载到将样式应用于 ActiveRow 的应用程序中,它仍然会显示。
如果你想更彻底地禁用活动行外观,完全忽略所有属性设置和样式库设置,可以这样做:
注意,这个属性是在 v9.2 中添加的,旧版本中不存在。
It's important to distinguish between Selected and Active. The grid never selects any rows automatically What you are seeing is the ActiveRow, which displays with a highlight just like the selected rows.
The grid's ActiveRow is synched up with the CurrencyManager, so by default the grid's first row appears highlighted. Resetting the ActiveRowAppearance and ActiveCellAppearance will remove the default highlight from the ActiveRow.
But it's important to note that this does not prevent the row from becoming the active row, it just that the grid no longer highlights the active row. Since the row is still active (and there is no way to prevent this) anything else that highlights the active row will still highlight the row. For example if you load a Style Library (*.isl) file into your application that applies a style to the ActiveRow, it will still display.
If you want to disable the active row appearance in a more thorough way, completely ignoring all property settings and Style Library settings, you can do this:
Note that this property was added in v9.2 and does not exist in older versions.
不知何故,上面列出的解决方案都不适合我。 就我而言,我只是希望根本不发生激活/选择。 所以我做了以下事情。 这可能不是最好的解决方案,但它确实有效。
Somehow none of the solutions listed above worked for me. In my case I simply wanted activation/selection not to happen at all. So I did the following. It may not be the best solution, but it works.
完全禁用选定的行,然后将
ActiveRow
设置为 null 应清除选择。Disable selected row altogether, then setting
ActiveRow
to null should clear the selection.