I am trying to understand how to put to use the Conditional Formatting Dialog. There is a boolean value on each row of data that will indicate if a row in the UltraWinGrid should be highlighted or not. I opened the Conditional Formatting Dialog for the boolean value, created a True Condition and set the appearance the way I want it. Now how do I get that appearance to apply to a row?
Sam
Hi,
I don't understand the issue. If you bind the grid to a BindingList<T>, then when you add an item to the BindingList, the grid will automatically be notified of the change via the IBindingList interface and fire the InitializeRow event.
You don't have to manually call the event. And in fact, you cannot do so, anyway.
Hi, I have been looking for an event that gets fired when adding to a bindinglist<someObject>. I have used BindingList<SomeObject> as my _grid.datasource. I add "SomeObject" from a different control to that object so I can't manually call initializerow() of my _grid or any other methods. My grid needs to know somehow that "Add" has been performed for display and then I can perform coloring operation based on cell v alue. Please tell me a way to resolve this problem.
Hi Sam,
scarleton said: The main thing I was looking for is data binding the whole row's appearance to a property, such that I would not have to write any additional code to manage the change of the appearance as the data changed. As the user interacts with the grid, the user is able to change the data such that the appearance of the whole row should change. From what I can tell, I will have to have my own event handler looking for changes in the data, the go find the corresponding row in the grid, then change that lines appearance.
The main thing I was looking for is data binding the whole row's appearance to a property, such that I would not have to write any additional code to manage the change of the appearance as the data changed. As the user interacts with the grid, the user is able to change the data such that the appearance of the whole row should change.
From what I can tell, I will have to have my own event handler looking for changes in the data, the go find the corresponding row in the grid, then change that lines appearance.
No, you don't have to do that. If you put code in the InitializeRow event, then that is all you will need. The event fires any time any value in the row changes. The event is s specifically designed to do exactly what you are trying to do here.
Mike,
Efficiency is always a concern of mine, so thank you for the link, like others said in response there, great post!
Question: Somewhere the UltraGrid has hooked the data source's PropertyChanged event. Is there any way to hook into that hook?
My thought process is: UltraGrid gets the PropertyChanged event, does it thing, in my case does nothing because it isn't a property that the UltraGrid knows anything about. Then the UltraGrid will pass the row and property information up to me, so I can change the appearance on just that one row. My code does not have to go figure out which UltraGrid row is associated with the data row that fired the PropertyChanged event.
I took a look at your sample and I don't see any ValueBasedAppearances (or any other appearances) applied by the sample.
In any case, I don't see any way to do what you want to do here using ValueBasedAppearances. The ValueBasedAppearance applies an appearance to a cell based on the value in that cell. I don't think you can apply an appearance to a cell based on the value of another cell in the row - unless maybe you use a formula condition and an UltraCalcManager.
If that's what you want to do, place an UltraCalcManager component on the form with the grid. Then you go into the grid designer and go to the ValueBasedAppearance property on either of the two name columns.
You click AddFormulaCondition and this will bring up the formula builder dialog. You have to write a formula that returns a boolean value. In this case, it's very simple - you just want the value of the IsHighlighted column. So your formula is:
[IsHighlighted]
Then you just set whatever properties you like on the Appearance for the conditionand repeat the process on the other column.
Note that this is not a very efficient way to do it. You will end up creating two identical appearances. Or more, if your real application has more than two columns to which you want the appearance to apply.
If you are concerned about efficiency, then it would be much better to simply use the InitializeRow event of the grid, examine the value of the IsHighlighted cell and apply an appearance to the row. There's more information about this in the WinGrid Performance Guide.