.net Infragistics UltraGrid:如何删除第一行的默认选择
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/639037/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Infragistics UltraGrid: how to remove default selection of first row
提问by Gerrie Schenck
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.
我在 WinForms 用户控件上放置了一个 UltraGrid。我调整了一些设置,以便可以将网格用作只读的多行选择表。但是有一个问题:默认情况下第一行似乎被选中。
But the Selected.Rowsproperty is empty, and also the ActiveRowproperty is null.
但是Selected.Rows属性是空的,而且ActiveRow属性也是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?
我确信 UltraGrid 上一定有隐藏的设置来控制这种行为。如果情况并非如此,那么也许有解决方法?
Thanks.
谢谢。
回答by Gerrie Schenck
After some more research I have found a solution, which I'll share with all of you:
经过一番研究,我找到了一个解决方案,我将与大家分享:
myUltraGrid.DisplayLayout.Override.ActiveCellAppearance.Reset();
myUltraGrid.DisplayLayout.Override.ActiveRowAppearance.Reset();
回答by stefano m
try this:
尝试这个:
this.ultraGrid1.SyncWithCurrencyManager = false;
this.ultraGrid1.DisplayLayout.Override.RowSelectors=DefaultableBoolean.False;
回答by stefano m
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;
我遇到了与您完全相同的问题,但 Gerrie Schenck 的解决方案对我不起作用。我使用了这个技巧:MyUltraGrid.ActiveRow = MyUltraGrid.Rows[0]; MyUltraGrid.ActiveRow = null;
回答by Vedat
This helped me in suppressing the "Active Appearance" of a grid:
这帮助我抑制了网格的“主动外观”:
grid.DisplayLayout.Override.ActiveAppearancesEnabled = Infragistics.Win.DefaultableBoolean.False;
If you also don't want a row to be marked as selected, you have to do the same for "Selected Appearance":
如果您也不希望将某一行标记为选中,则必须对“选中的外观”执行相同操作:
grid.DisplayLayout.Override.SelectedAppearancesEnabled = Infragistics.Win.DefaultableBoolean.False;
回答by Mike
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.
区分 Selected 和 Active 很重要。网格从不自动选择任何行 您所看到的是 ActiveRow,它与所选行一样突出显示。
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.
网格的 ActiveRow 与 CurrencyManager 同步,因此默认情况下,网格的第一行会突出显示。重置 ActiveRowAppearance 和 ActiveCellAppearance 将从 ActiveRow 中删除默认突出显示。
this.ultraGrid1.DisplayLayout.Override.ActiveCellAppearance.Reset();
this.ultraGrid1.DisplayLayout.Override.ActiveRowAppearance.Reset();
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.
但重要的是要注意,这不会阻止该行成为活动行,只是网格不再突出显示活动行。由于该行仍然处于活动状态(并且没有办法防止这种情况),任何突出显示活动行的其他内容仍将突出显示该行。例如,如果您将样式库 (*.isl) 文件加载到将样式应用于 ActiveRow 的应用程序中,它仍将显示。
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:
如果您想以更彻底的方式禁用活动行外观,完全忽略所有属性设置和样式库设置,您可以这样做:
this.ultraGrid1.DisplayLayout.Override.ActiveAppearancesEnabled = Infragistics.Win.DefaultableBoolean.False;
Note that this property was added in v9.2 and does not exist in older versions.
请注意,此属性是在 v9.2 中添加的,在旧版本中不存在。
回答by Jeff
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.
不知何故,上面列出的解决方案都不适合我。就我而言,我只是希望根本不发生激活/选择。所以我做了以下事情。它可能不是最好的解决方案,但它有效。
private void LayoutVisulizerUltraGrid_AfterRowActivate(object sender, EventArgs e)
{
LayoutVisulizerUltraGrid.ActiveRow = null;
}
回答by Rytis I
Disable selected row altogether, then setting ActiveRowto null should clear the selection.
完全禁用选定的行,然后设置ActiveRow为 null 应清除选择。
grid.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.None;

