Question

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.

Was it helpful?

Solution

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();

OTHER TIPS

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;

try this:

this.ultraGrid1.SyncWithCurrencyManager = false;
this.ultraGrid1.DisplayLayout.Override.RowSelectors=DefaultableBoolean.False;

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;

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.

        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.

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.

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;
    }

Disable selected row altogether, then setting ActiveRow to null should clear the selection.

grid.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.None;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top