|
-
Oct 19th, 2001, 10:57 AM
#1
Thread Starter
New Member
Selecting Items in List Box control programmatically...
Hi ,
I have created list box with the property Multiselect= 2-extended.
I thought I can select more than one Item in the list box programmaticaly using the following code, but it is not working.
For i= 2 to SelctedVal
retval = SendMessage(lstNotLinked.hWnd, LB_SETSEL,
ByVal CLng(1), ByVal CLng(i))
Next i
Can some body please tell me whether it is possible OR not.
Since I am new to VB, I am not very sure of VB 6.0 capabilities.
If any of you know how to select the list box items (more than one) programmatically then please let me know.
Thank You very much........
-
Oct 19th, 2001, 11:29 AM
#2
PowerPoster
Is there any particular reason you are using API, as this will do
VB Code:
For i = 0 To List1.ListCount - 1 Step 2 'select every other element
List1.Selected(i) = True
Next i
-
Oct 19th, 2001, 11:37 AM
#3
Thread Starter
New Member
Selecting Items in List Box control programmatically...
The foloowing code just select the item, but the items do not get hilighted in the list box. i.e I wanted to see those selcetd Items (List1.Selected(i) = True) as hilighted in the list box.
For i = 0 To List1.ListCount - 1 Step 2 'select every other element
List1.Selected(i) = True
Next i
Thank you...
SESHU
-
Oct 19th, 2001, 11:42 AM
#4
PowerPoster
It does highlight them, provided MultiSelect is set to Simple or Extended
-
Oct 19th, 2001, 11:46 AM
#5
Thread Starter
New Member
It is Multiselect is Extended
-
Oct 19th, 2001, 11:49 AM
#6
Thread Starter
New Member
But, I am doing it in on click event of the same list box , does it causes any problem?
Thanks
-
Oct 19th, 2001, 11:49 AM
#7
PowerPoster
-
Oct 19th, 2001, 11:50 AM
#8
PowerPoster
Originally posted by bs2527
But, I am doing it in on click event of the same list box , does it causes any problem?
No that doesn't appear to cause a problem
-
Oct 19th, 2001, 11:57 AM
#9
Thread Starter
New Member
Here is my problem,
I have list box with few items, If user selects one Item say 1,
then the program will automatically selects 4,5 & 6(Hilights). The selection logic for 4,5 &6 I kept in the on click event for 1, but
It is not working...
Hope you understand my problem...
-
Oct 20th, 2001, 07:52 AM
#10
Thread Starter
New Member
I have tried that also, but no luck!!!!!!
Is there any way to do it by generating the event for Shift key + selection , programmatically..
Thanks for your help.
-
Oct 20th, 2001, 08:01 AM
#11
PowerPoster
What do you mean no luck? The code works fine for me. U have set the MultiSelect property to 1 havent u?
what exactly is not working?
Regards
Stuart
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|