
Originally Posted by
Eliminator2009
When a use clicks on a row or column the column or row must be HiLighted to any color.
is it possible ?
Try this:
Code:
Option Explicit
Private Sub Form_Load()
'~~~ Adding some text for testing purpose (create two column headers in design time)
Dim i As Long
For i = 1 To 50
ListView1.ListItems.Add , , i
ListView1.ListItems(i).SubItems(1) = i
Next
End Sub
'~~~ When we click on it
Private Sub ListView1_Click()
ColorListviewRow ListView1, ListView1.SelectedItem.Index, vbRed '~~~ We are passing the Listview's name, selected item's index and the color to the sub
End Sub
'~~~ Sub for coloring
Public Sub ColorListviewRow(lv As ListView, sel_Item As Long, Color1 As OLE_COLOR)
Dim itmX As ListItem
Dim lvSI As ListSubItem
Dim intIndex As Integer, i As Integer
On Error GoTo ErrorRoutine
Set itmX = lv.ListItems(sel_Item)
itmX.ForeColor = Color1
For intIndex = 1 To lv.ColumnHeaders.Count - 1 '~~~ Coloring the full row with the selected color
Set lvSI = itmX.ListSubItems(intIndex)
lvSI.ForeColor = Color1
DoEvents
Next
Set itmX = Nothing
Set lvSI = Nothing
Exit Sub
ErrorRoutine:
MsgBox Err.Description
End Sub
.....