Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Controls
  New Posts New Posts RSS Feed - ListBox - check on click
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ListBox - check on click

 Post Reply Post Reply
Author
Message
coffeemkr0 View Drop Down
Newbie
Newbie


Joined: 27 March 2008
Location: United States
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote coffeemkr0 Quote  Post ReplyReply Direct Link To This Post Topic: ListBox - check on click
    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?
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
coffeemkr0 View Drop Down
Newbie
Newbie


Joined: 27 March 2008
Location: United States
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote coffeemkr0 Quote  Post ReplyReply Direct Link To This Post 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));

    }

}

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.