Print Page | Close Window

ListBox - check on click

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=11117
Printed Date: 12 May 2024 at 11:05am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: ListBox - check on click
Posted By: coffeemkr0
Subject: ListBox - check on click
Date Posted: 19 June 2008 at 6:24pm
I was wondering if it is possible with the XtremeListBox control to make it so that when a user selects an item it will also check/uncheck the check box for that item.
 
I don't see any selected index changed event or any event that will basically tell me when an item is clicked. 
 
I originally thought I had solved the problem by simulating rectangles around each item in the list and then checking the mouse position in the mouse down event.
 
However, this solution does not work if the user scrolls the list box and as far as I can tell, there is also no way to tell when the list box is scrolled.
 
Is there any way to implement this?



Replies:
Posted By: jpbro
Date Posted: 19 June 2008 at 10:13pm
I think the Click event is what you are looking for...try this:


Private Sub ListBox1_Click()
   With Me.ListBox1
      .Checked(.ListIndex) = Not .Checked(.ListIndex)
   End With
End Sub





-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: coffeemkr0
Date Posted: 20 June 2008 at 2:02pm
Originally posted by jpbro jpbro wrote:

I think the Click event is what you are looking for...try this:


Private Sub ListBox1_Click()
   With Me.ListBox1
      .Checked(.ListIndex) = Not .Checked(.ListIndex)
   End With
End Sub



 
Haha, ListIndex, that is what I was missing :)  Leave it to me to make something easy way too complicated.
 
Anyways, here is the final solution I came up with in case someone else has this issue.
I added a rectangle that covers the check boxes.  If the cursor is inside that rectangle then it does nothing since this is the user clicking on the check box instead of the item.
 
 

private void AxListBox_ClickEvent(object sender, EventArgs e)

{

    AxXtremeSuiteControls.AxListBox objListBox = (AxXtremeSuiteControls.AxListBox)sender;

    Rectangle r = new Rectangle(0, 0, 15, objListBox.Height);

    if (!r.Contains(objListBox.PointToClient(Cursor.Position)))

    {

        objListBox.set_Checked(objListBox.ListIndex, !objListBox.get_Checked(objListBox.ListIndex));

    }

}




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net