c# - How to change the backcolor of a listview subitem using its own value -


How can I change the program behind the color of a single cell using my values ​​in listview?

alt text

The value in the color palp column comes from the database .

Here's my code:

  foreach (DataRow dr in _dataTbl.Rows) {_markow = dr ["mark"]. ToString (); _stock = DR ["stock"]. Toasting (); _SteelSectio = dr ["steelsection"]. ToString (); _colo = (Int32) dr ["color"]; ListViewItem _lvi = New ListViewItem (_markow); _lvi.SubItems.AddRange (new string [] {_ steelcacheto, _stock, _colo.ToString ()}); _myListView.Items.Add (_lvi); }  

Here is the code that I have tried to replace backcolor cells:

 for  (int _i = 0; _i & lt; _owLV Item. Calculation; _i ++) {_myListView.Items [_i] .UseItemStyleForSubItems = false; _myListView.Items [_i] .SubItems [3]. Outstanding color = color FROMArgb (_colo); }  

Thanks in advance

As far as I tell I think the code looks ok, I threw a quick Windows Form application together and threw a list view on the form in detail in two columns in detail. The following code works fine.

  var item1 = New ListViewItem ("Item 1"); Item1.SubItems.Add ("Color"); Item1.SubItems [1]. Back collar = color. FormArgb (-16711 936); Item1.UseItemStyleForSubItems = false; List View 1. item. Add (item 1);  

I try to set the backender before adding the item. It seems that you are setting all the objects in one color, which you probably do not want.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -