16

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.

Jeff Atwood
  • 63,320
  • 48
  • 150
  • 153
Gerrie Schenck
  • 22,148
  • 20
  • 68
  • 95

7 Answers7

22

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();
Gerrie Schenck
  • 22,148
  • 20
  • 68
  • 95
  • Didn't work for me or Gianni. And Gianni's approach blows away the ListObject data. Can you offer any help why it may not have worked? I took a simple grid with the default properties and bound it and thene xecuted the recommended 2 lines. No change. – Chad Mar 02 '11 at 20:19
  • This worked for me. For those of you with a similar issue, keep in mind that there are two properties that a row can have: 'Selected' and 'Active'. Zero or more rows may be Selected, but one and only one row is Active. Unfortunately, both a Selected row and the Active row are (by default) highlighted in the same way. The Active row is also indicated by a triangle in the row header (if you have row headers enabled.) The ActiveRowAppearance.Reset() call tells the UltraGrid to not highlight the active row. Hope this helps. – AlfredBr Sep 04 '14 at 17:42
5

try this:

this.ultraGrid1.SyncWithCurrencyManager = false;
this.ultraGrid1.DisplayLayout.Override.RowSelectors=DefaultableBoolean.False;
stefano m
  • 4,094
  • 5
  • 28
  • 27
5

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;
Vedat
  • 61
  • 1
  • 5
4

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;

3

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.

Mike
  • 206
  • 1
  • 7
1

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;
    }
Jeff
  • 8,020
  • 34
  • 99
  • 157
0

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

grid.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.None;
Rytis I
  • 1,105
  • 8
  • 19