?
Solved

Listbox question

Posted on 2003-02-19
6
Medium Priority
?
290 Views
Last Modified: 2010-04-17
I have a 2 listbox that has the same value or contents are the same.

My question is how can i disable the other if the first value has been already selected?

Listbox 1
A <- Selected
B
C
D


Listbox 2
A <- Cannot be selected
B
C
D

I have tried using if but i have a 20 list items in my listbox.
0
Comment
Question by:TheGameEdge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 16

Expert Comment

by:twalgrave
ID: 7984878
You cannot disable individual items from a listbox.  Sorry!

What you could do is on the Click event, scan listbox2 and see if that item is already selected.  If it is, set the listindex of listbox1 to -1 (not friendly behavior!).
0
 
LVL 16

Accepted Solution

by:
twalgrave earned 300 total points
ID: 7984883
What I mean to say is something like this:

private sub List1_Click()
   if list1.listindex > -1 then
      if list2.listindex > -1 then
         if list2.list(list2.listindex) = list1.list(list1.listindex) then
            list1.listindex = -1
         endif
      endif
   endif
end sub
0
 

Expert Comment

by:luisseixas
ID: 7985106
Try to do somethig like this...



procedure TForm1.List1Click(Sender: TObject);
var i: Integer;
begin
  For i:=0 to List1.Items.Count-1 do
    If (List0.Selected[i]) AND (List1.Selected[i])
      then List1.ItemIndex:=-1;
end;
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 27

Expert Comment

by:Dabas
ID: 7985323
I suggest you use listview in report style instead of listboxes

Same effect and once you have the hang of it, so much easier to format!
An extra advantage is that you have extra features such as extra columns, checkboxes, etc

Dabas
0
 
LVL 1

Expert Comment

by:cybeonix
ID: 7986180
What you are trying to do is mutual exclusion, I assume. You might consider using is the listview control and enable the LVS_EX_CHECKBOXES option for the Extended Styles.

You can check the status of these checkboxes and use them however you wish, if its checked, you can prevent it from being unchecked. (you could enable the checkbox simply when the user selects the item in the list)
0
 
LVL 3

Expert Comment

by:FaithRaven
ID: 9307493
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept twalgrave's comment
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

FaithRaven
EE Cleanup Volunteer
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question