Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiselection problem

Status
Not open for further replies.

231166

Programmer
Apr 5, 2005
104
FR
Hi,

I send this problem for the second time because the code i have received in response to it did'nt work well

When i click in a listview called listview1 the selected term color becomes 'magenta'(its highlighttext).

The fact is that when i select another term of the listview1, its color becomes also 'magenta' but the first selected term remains with color 'magenta', what i don't want to.

how can i correct this to see only the last selected term in magenta color in the listview1

Here is the code of the click event on the listview1.


CODE

Private Sub ListView1_ItemActivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.ItemActivate
Dim iSelectedTermeID As Integer, strLibTerme As String
'Dim nNode1 As TreeNode

'déclaration de deux arrays qui vont contenir plusieurs lignes
Dim drNAs() As DataRow, drSyns() As DataRow, drNA As DataRow, drSYN As DataRow
Dim nNANode As TreeNode, nSynNode As TreeNode


If Not ListView1.FocusedItem Is Nothing AndAlso Not ListView1.FocusedItem.Tag Is Nothing Then
' ListView1.FocusedItem.ForeColor = SystemColors.HighlightText.Magenta
iSelectedTermeID = CType(ListView1.FocusedItem.Tag, Integer)



[/CODE]

Secondly,

When i select one term in the listview1, this term appears also selected in a treeview called 'treeview1' (below the listview1) and its backcolor becomes DeepSkyBlue ( in the treeview1).

the problem is that when i select another term in the listview1, the first selected term remains selected in the treeview1 with its backcolor DeepSkyBlue, what i don't want.
I only want the last selected term with backcolor = deepskyblue.

Could you help me on this point.


Thanks a lot for your help.

Best regards

Here is the code of the listview1_itemactivate

CODE
Private Sub ListView1_ItemActivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.ItemActivate

Dim iSelectedTermeID As Integer
Dim nNode1 As TreeNode


If ListView1.SelectedItems.Count > 0 Then
iSelectedTermeID = ListView1.SelectedItems(0).Tag
nNode1 = FindNode(iSelectedTermeID, TreeView1.Nodes)

If Not nNode1 Is Nothing Then
'TreeView1.Focus()
TreeView1.SelectedNode = nNode1

nNode1.BackColor = SystemColors.Highlight.DeepSkyBlue
nNode1.ForeColor = SystemColors.HighlightText.MediumSlateBlue
nNode1.ExpandAll()

End If


[/CODE]

 
simple

Code:
private prevnode as treenode 

Private Sub ListView1_ItemActivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.ItemActivate
        Dim iSelectedTermeID As Integer, strLibTerme As String
        'Dim nNode1 As TreeNode

        'déclaration de deux arrays qui vont contenir plusieurs lignes
        Dim drNAs() As DataRow, drSyns() As DataRow, drNA As DataRow, drSYN As DataRow
        Dim nNANode As TreeNode, nSynNode As TreeNode

        
        If Not ListView1.FocusedItem Is Nothing AndAlso Not ListView1.FocusedItem.Tag Is Nothing Then
            prevnode.forcolor = color.black
            ' ListView1.FocusedItem.ForeColor = SystemColors.HighlightText.Magenta
            iSelectedTermeID = CType(ListView1.FocusedItem.Tag, Integer)

prevnode = ListView1.FocusedItem


Christiaan Baes
Belgium

"My new site" - Me
 
Hi and thanks for your answer.
First, prevNode=ListView1.FocumsedItem is not correct because prevNode is a treenode.
What i have tried is to declare prevNode as an integer which receives the value of TreeView1.SelectedNode.Index
The problem is that i always see the value of TreeView1.SelectedNode.Index =0 and i don't unsderstand why.
If you could help me on this point it would be very kind from you.

Thanks a lot for your help.

Regards.
Nathalie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top