bjwade62 Posted May 24, 2006 Posted May 24, 2006 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?? Quote
Leaders snarfblam Posted May 24, 2006 Leaders Posted May 24, 2006 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? Quote [sIGPIC]e[/sIGPIC]
bjwade62 Posted May 24, 2006 Author Posted May 24, 2006 Yes the list view has focus. I'm using button2 to active a ContextMenu. Is that what you mean? Thanks. Quote
Leaders snarfblam Posted May 25, 2006 Leaders Posted May 25, 2006 Can you post the code that shows the menu? Quote [sIGPIC]e[/sIGPIC]
bjwade62 Posted May 25, 2006 Author Posted May 25, 2006 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? Quote
bjwade62 Posted May 25, 2006 Author Posted May 25, 2006 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? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.