Hi,
I was trying to clear the selected rows of an ultragrid from an external sub (inside the same from).
I already read the forum (mainly http://www.infragistics.com/community/forums/t/26429.aspx) and i tried with several different attempts, but nothing is working.
Here you are what I tried with no effects (alternative attempts):
GridReports.DisplayLayout.Override.SelectTypeRow = SelectType.None
GridReports.ActiveRow.Selected = False
GridReports.ActiveRow = Nothing GridReports.DisplayLayout.Override.ActiveRowAppearance.Reset()
GridReports.SyncWithCurrencyManager = False GridReports.DisplayLayout.Override.RowSelectors = DefaultableBoolean.False
GridReports.DisplayLayout.Override.ActiveAppearancesEnabled = Infragistics.Win.DefaultableBoolean.False
GridReports.Refresh() 'In order to refresh the grid
What is missing?
Many thanks
Alberto
Hi Alberto,
Thank you for posting in our forums!
Let’s clarify you scenario. By clearing the selected rows you mean, resetting their appearance and state of selected to unselected and by using external sub in the same form, you mean clicking on a button for which explicitly forces this action.
The first approach I came with is subscribing to a button click event and type the following code inside it.
In this case I take advantage of using a lambda function, in order to filter all rows that have been selected and then I just unselect every one of them.
Please let me know if you that works for you.
unfortunately it does not work: it flows thru' the selected cell, but after the row remain selected (highlighted in blue)
Do I have to refresh somehow the grid? (or where is the trick?)
In fact you don’t have to refresh explicitly the grid and there is not magic trick for this action. It seems that somewhere in your code, when a row is selected a new appearance object is initialized with back color similar to the highlighted color. In this scenario you can either find and remove this code or in addition to the provided code explicitly reset the appearance of all selected rows.
I am waiting for your feedback.
I see your point. After the code you suggested, if i run a test (looping across all rows) no rows seems to be selected
However as you can see in the following Screenshot, the grids seems to be still with selected rows (I how you can see my copy & paste attachment
The question should be: how can I display tables without any on these blu rows?
Thanks
Although I am not able to see your screenshot, I see what you are trying to accomplish.
In case your application uses an AppStylist library, you want to prevent the grid of applying these appearances. Second, you want to make sure that the default selected back color is reset and optionally you can even reset all appearances and apply your own after that. This all should happen ideally on the bottom of the main form’s load event.
Let me know if you have any additional questions.
Hi
I already set the 'GridReports.UseAppStyling = False' in order to be able to change the color set of the grid.
The idea, should be not to reset the appearance, but to show the Grid without any highlighted row. It is like when you open an excel file: you don't see any row selected until you click on the screen
Maybe this is not how Infrgistics is working in this way (one line is always highlighted). Pls, let me know in case I'm wrong
The only solution I found to "clear" definetively the grid is the following
GridReports.DisplayLayout.Override.ActiveRowAppearance.BackColor = Color.TransparentGridReports.Refresh()
I noticed that you need to refreshm in order to apply the changes
Hi Alberto
It is vital to distinguish that there could be more than one selected row and only one activated (highlighted). I understand you are trying to show the grid without any activated (highlighted) row without modifying or resetting active row’s appearance. By default active row’s background color is transparent and if you don’t have any other appearance properties set, you can simply call its reset method. Then the grid will be refreshed for you, without calling the refresh method explicitly.
By default the grid is shown with activated first row and if you have any initialized active cell appearance it would be applied. However there is a way to prevent, first row’s activation. You can set the SyncWithCurrencyManager property to False to prevent the grid from synchronizing the active row with the associated currency manager's position. This property is useful if you have a lot of deeply nested bands and navigation through the rows is very slow.
Please let me know if you have any further questions.
Thank you for using Infragistics Components!