User (Old forums)MemberMarch 7, 2006 at 9:03 amPost count: 23064
I have a row that has a colum of type bool, so with a checkbox in it.
I want to paint the row in a different color at once when the checkbox is enabled.
I already managed to do so by handling the DataRowsChanged event of the grid but this has two disadvanteges:
a) I have to look at all rows in the grid.
b) the row is not colored at once but when I leave the edit mode of the row
An event that is raised just when the editing of the row is ended would be the best, but somehow I could not get it working.
Imported from legacy forums. Posted by sebastian (had 3801 views)User (Old forums)MemberMarch 9, 2006 at 9:25 amPost count: 23064
Have you tried CellValueChanged event of a row. If you’re hooking into events then you’d have to add a handler to each row in your grid and then the data row would be the sender, but that’s not very efficient and easy to work with. A better way would be to inherit from the Xceed.Grid.DataRow class and create your own row. In that way when a cell value changes you can change the colour of the current row with minimal code and effort.
protected override void OnCellValueChanged(System.EventArgs e)
BackColor = System.Drawing.Color.White;
BackColor = System.Drawing.Color.Red;
It’s an idea anyway.
Imported from legacy forums. Posted by Chris (had 273 views)User (Old forums)MemberMarch 9, 2006 at 9:40 amPost count: 23064
Yes I have tried several different events but they don’t work.
What I really want is that the row is colored green when the checkbox in the cell gets marked and it should become white again, when it is unmarked.
This seems not be possible because all events are either raised before or after editing but not at once.
I think even with writing my own Row or Cell Class it would not work because the event is just raised at the wrong time.
Imported from legacy forums. Posted by sebastian (had 456 views)User (Old forums)MemberMarch 9, 2006 at 9:51 amPost count: 23064
I think that way should work. I’m using it now in one of my grids to change the colour of a row depending on the values in that row.
The other way is that if you’re using a cell editor attached to it’s changed event so if it’s a check box attach to it’s CheckedChanged event.
Imported from legacy forums. Posted by Chris (had 375 views)User (Old forums)MemberMarch 9, 2006 at 11:33 amPost count: 23064
I don’t understand the last sentence 🙁
Could you give a code example of your working code?
Imported from legacy forums. Posted by sebastian (had 245 views)User (Old forums)MemberMarch 9, 2006 at 11:37 amPost count: 23064
It was along the lines of if you set the cell editor of the cell to a check box but you’re not doing that. My mistake.
You should be able to catch the CellValueChanged event in the row so I’m a bit confused. As I said the best way would be to inherit from the DataRow object and handle it that way.
That is if I understand what you want correctly.
Imported from legacy forums. Posted by Chris (had 5086 views)
- You must be logged in to reply to this topic.