DataBinding a DataGridview rows BackColor?

I think the problem is files. DisplayColor files is a collection an has no property DisplayColor but each item of the collection has. So you are trying to bind a not existing property.

Further binding collection DataGridView. DataBindings allows you to data bind properties of the control, not of its rows. There is only one DataGridView.

DefaultCellStyle. BackColor for all rows. So I believe you end up needing to bind the DefaultCellStyle of each row to the coresponding item from files and I am not sure if this is possible.It might be that the DataGridView creates and deletes rows as required - for example if you perform filtering - and this will destroy the data binding, too.

I think the problem is files.DisplayColor. Files is a collection an has no property DisplayColor but each item of the collection has. So you are trying to bind a not existing property.

Further binding collection DataGridView. DataBindings allows you to data bind properties of the control, not of its rows. There is only one DataGridView.

DefaultCellStyle. BackColor for all rows. So I believe you end up needing to bind the DefaultCellStyle of each row to the coresponding item from files and I am not sure if this is possible.It might be that the DataGridView creates and deletes rows as required - for example if you perform filtering - and this will destroy the data binding, too.

So, I am not sure if row coloring can be done with data binding, but I personaly doubt it. This would require some really smart logic recognicing 'bind the property DisplayColor of the object data bound to this row to the property DefaultCellStyle. BackColor of this row.

' You could surly implement such an smart data binding. While it would be a great thing, it will be quite complex, too.As a simple solution you could just use the RowPrepaint event to set the correct color for the row.

I just wanted to point out the first two sentences are incorrect, but everything else I agree with. I went with RowPrepaint in the end. Thanks for your help.

When binding the datasource (files) can be a collection, and the databinding property will be from the active object in that collection (and files0. DisplayColor is valid based on my objects). I already use this approach on another form.I.e.

TxtServerAddress.DataBindings. Add("Text", m_Profiles, "ServerAddress"); Bind txtServerAddress. Text, to the active Profile.

ServerAddress value. – MattH May 22 '09 at 10:18.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions