Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I recently moved a listview control inside a SplitContainer. I have a contextmenu_click event containing the following code.

If ActiveControl.Name = lvwLeftList.Name Then...

The problem is the ActiveControl is the SplitControl not the listview inside it. Bug??

  • Leaders
Posted

Are you using it under the correct circumstances?

In order to receive a valid value from this property, the object that calls it must either contain or be contained in the control it is calling. If one form tries to call another form's ActiveControl properties, it will receive an undefined value. In this case, you need to define your own communication mechanism between the forms to pass this data

[/Quote]

And you are sure that the ListView has focus when this code is being executed, right? How is the context menu being displayed? Via the ContextMenu property of the control?

[sIGPIC]e[/sIGPIC]
Posted

Sure, here it is. It worked fine as is until I put the ListView in the SplitterControl. Thanks again.

 

   Private Sub cmnuSelectAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmnuSelectAll.Click
       If ActiveControl.Name = lvwLeftList.Name Then
           Dim ListLeft As ListViewItem
           For Each ListLeft In lvwLeftList.Items
               If ListLeft.ImageIndex <> 5 Then
                   ListLeft.Selected = True
               End If
           Next
       End If
       If ActiveControl.Name = lvwRightList.Name Then
           Dim ListRight As ListViewItem
           For Each ListRight In lvwRightList.Items
               If ListRight.ImageIndex <> 5 Then
                   ListRight.Selected = True
               End If
           Next
       End If
   End Sub

 

 

Can you post the code that shows the menu?
Posted

Here's the solution in case anyone else needs it in the future.

 

If SplitContainer1.ActiveControl Is lvwLeftList Then

'...

ElseIf SplitContainer1.ActiveControl Is lvwRightList Then

'...

End If

 

Got it from someone at another forum.

 

Can you post the code that shows the menu?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...