Highlight specific rows in a ListView

Can someone help me on how to highlight specific ListView rows in vb.net?

+3
source share
2 answers

Suppose you have this in detail mode, just make sure that FullRowSelect and MultiSelect are set to true, and then just set the Selected property on the elements (rows) that you want to set to true. Assuming you have a ListView called ListView1, the following should work:

ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)  
ColumnHeader2 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)  
ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1, Me.ColumnHeader2})  

ListView1.View = View.Details  
ListView1.MultiSelect = True  
ListView1.FullRowSelect = True  
ColumnHeader1.Width = -2  
ColumnHeader2.Width = -2  

For index As Integer = 0 To 3  
    ListView1.Items.Add("Number" & index.ToString()).SubItems.Add("text")  
Next  
ListView1.Items(1).Selected = True  
ListView1.Items(3).Selected = True
+1
source

I believe that you can catch ItemDataBoundEvent and set the css class in your lines. This example shows concepts:

http://msdn.microsoft.com/en-us/library/bb350797(v=VS.100).aspx

runat = "server" , FindControl.

, (tr, div ..), (, ..). ( ), .

css, , "Selected".

0

Source: https://habr.com/ru/post/1741550/


All Articles