When I load a grid, the first row is highlighted. I only want it to be highlighted or activated once I click on it. Is there a way to deactivate this on load up but keep it when I do click on a row?
Hi,
The grid does not automatically activate a row. The grid's ActiveRow is synchronized with the current row of the CurrencyManager. So if the grid is showing up with an active row, it must be because the CurrencyManager is positioned to that row.
You can set SynchWithCurrencyManager to false on the grid and this will disable the synchronization. But keep in mind that if you do this, you can't rely on the CurrencyManager being in synch with the grid. This may not matter to you, depending on the needs of your application.
Another option might be to reset the grid.DisplayLayout.Override.ActiveRowAppearance and ActiveCellAppearance so that the ActiveRow doesn't appear highlighted. Then you can deal with Selected rows instead of the ActiveRow.
Hi Mike,
I'm having the same issue. I need the grid to show which row is active; I just don't want the grid to automatically select a row initially. I tried setting SyncWithCurrencyManager to false, but that didn't seem to change anything.
The call stack tells me the grid's ActiveRow property is being set by the RowsCollection.InitGroupByRows method. Reflector tells me that this method sets a private boolean field (inInitGroupByRows) to true which is set back to false at the end of the method. So, here's my solution. Is there a better way to do this that doesn't involve using reflection to get the value of a private field?
private void OnGridAfterRowActivate(object sender, EventArgs e) { if (this.IsGridInitializingGroupByRows() && this.Grid.ActiveRow != null) { this.Grid.ActiveRow = null; } }
private bool IsGridInitializingGroupByRows() { return (bool)this.Grid.Rows.GetType().InvokeMember("inInitGroupByRows", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance, null, this.Grid.Rows, null); }
The grid always sets the ActiveRow to the first GroupByRow when you group. There is currently no way to stop this from happening.
But it looks like there is no particular appearance applied to the active GroupByRow in the grid, anyway. What you are seeing is most likely the highlight because the first GroupByRow is selected. I don't think there is any way to stop this from happening, but you can clear the selection after the grid is grouped.
It's a bit tricky, though, since the grouping normally happens asynchronously.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGrid grid = (UltraGrid)sender; e.Layout.ViewStyleBand = ViewStyleBand.OutlookGroupBy; e.Layout.Bands[0].SortedColumns.Add("Int32 1", false, true); // We need to force the verification of the child elements so that the grouping and // selection of the first row happen immediately. e.Layout.UIElement.VerifyChildElements(); //grid.ActiveRow = null; grid.Selected.Rows.Clear(); }