Hi,
I'm trying to load my grid and to remove the default selection and the default active row (row selector) on the first load. Normally in a simple project, i just set my grid's ActiveRow to null and clear my Selected rows by doing the following code
this.ultraGrid.ActiveRow = null;
this.ultraGrid.Selected.Rows.Clear();
As I said, in a normal simple project, this works fine. Except i'm working on a little more complicated project, which for some reason this code doesn't work as intended. Even if i set the ActiveRow to null, my dataTable's first record is always set as the ActiveRow.
What's even weirder, is that i can't seem to figure out where the code is being fired from. From the call stack, it seems to be called by Infragistics internal code, looks like it's trying to "Ensure" that an ActiveRow is assigned. Is there another property somewhere that can change the behavior of the UltraGrid to not set the ActiveRow when initially loading the grid? I'm posting my call stack to show you that after loading my grid, initialize the layout and set the ActiveRow to null, the "BeforeRowActivate" event fires on it's own.
> VSEConnector.dll!VSEConnector.Framework.Search.AdvancedSearch.grdResults_BeforeRowActivate(object sender = {Infragistics.Win.UltraWinGrid.UltraGrid}, Infragistics.Win.UltraWinGrid.RowEventArgs e = {Infragistics.Win.UltraWinGrid.RowEventArgs}) Line 1833 C# Infragistics2.Win.UltraWinGrid.v5.3.dll!Infragistics.Win.UltraWinGrid.UltraGrid.OnBeforeRowActivate(Infragistics.Win.UltraWinGrid.RowEventArgs e = {Infragistics.Win.UltraWinGrid.RowEventArgs}) + 0x61 bytes Infragistics2.Win.UltraWinGrid.v5.3.dll!Infragistics.Win.UltraWinGrid.UltraGrid.FireEvent(Infragistics.Win.UltraWinGrid.GridEventIds id = BeforeRowActivate, System.EventArgs e = {Infragistics.Win.UltraWinGrid.RowEventArgs}) + 0x501 bytes Infragistics2.Win.UltraWinGrid.v5.3.dll!Infragistics.Win.UltraWinGrid.UltraGrid.OnActiveRowChange(Infragistics.Win.UltraWinGrid.UltraGridRow newActiveRow = {Infragistics.Win.UltraWinGrid.UltraGridRow}, bool scrollIntoView = false) + 0xed bytes Infragistics2.Win.UltraWinGrid.v5.3.dll!Infragistics.Win.UltraWinGrid.UltraGridBase.SetActiveRow(Infragistics.Win.UltraWinGrid.UltraGridRow row = {Infragistics.Win.UltraWinGrid.UltraGridRow}, bool scrollIntoView = false) + 0x95 bytes Infragistics2.Win.UltraWinGrid.v5.3.dll!Infragistics.Win.UltraWinGrid.UltraGrid.EnsureTempActiveRowAssigned() + 0x15d bytes Infragistics2.Win.UltraWinGrid.v5.3.dll!Infragistics.Win.UltraWinGrid.UltraGridBase.PaintTimer_Tick(object source = {Interval = 1000}, System.EventArgs e = {System.EventArgs}) + 0x91 bytes System.Windows.Forms.dll!System.Windows.Forms.Timer.OnTick(System.EventArgs e) + 0x17 bytes System.Windows.Forms.dll!System.Windows.Forms.Timer.TimerNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0x36 bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg = 275, System.IntPtr wparam, System.IntPtr lparam) + 0x75 bytes [Native to Managed Transition] [Managed to Native Transition] System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int dwComponentID, int reason = -1, int pvLoopData = 0) + 0x2ea bytes System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason = -1, System.Windows.Forms.ApplicationContext context = {System.Windows.Forms.ApplicationContext}) + 0x17d bytes System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x53 bytes System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) + 0x2e bytes Company.AppName.UI.AppEnvironment.exe!Company.AppName.UI.Program.Main(string[ args = {Dimensions:[0]}) Line 178 + 0xb bytes C#
Any help would be appreciated,
Thanks
By default, the grid synchronizes it's ActiveRow with the current Position of the CurrencyManager. From the call stack, my guess is that the first time the grid paints, it's trying to activate the approriate row based on the current row of the data source.
I'm pretty sure that the CurrencyManager cannot have a null position - it always has an active row, unless there are no rows at all. I could be wrong about this, so it's something you might want to explore.
Another option would be to turn off the grid's synchronization with the CurrencyManager. You could set grid.DisplayLayout.SynchWithCurrencyManager to false. This should prevent the grid from activating the row the first time it paints. But there are, of course, other implications to this. If you are relying ont he grid to be in synch with the CurrencyManager, then this is not a good solution.
If that doesn't help, then the only thing you can do is turn off the ActiveRowAppearance. You can reset grid.DisplayLayout.Override.ActiveRowAppearance and ActiveCellAppearance. There will still be an active row in the grid, but it will not be highlighted.
Thanks for the reply,
I think the CurrencyManager and the synchronization your talking about is not part of the UltraGrid version we're using. We're still using Infragistics version 5.3.
As far as changing the ActiveRowAppearance, that's could work, but it's not part of the design and wouldn't be standard with the rest of the application. I'll keep this as my very last option.
For now i think what's best is to just go to an alternative solution & change the design and hope i dont encounter another similar situation.
regards,
xinull said: I think the CurrencyManager and the synchronization your talking about is not part of the UltraGrid version we're using. We're still using Infragistics version 5.3.
The CurrencyManager is part of the DotNet DataBinding implementation. It's not specific to the WinGrid, it's built-in to the DotNet framework. So it exists in all versions of DotNet. The SynchWithCurrencyManager property on the grid may not exist in v5.3, though. It was probably added in a later version.