Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

tComboBox with unselecteble items

Posted on 2011-02-17
4
Medium Priority
?
327 Views
Last Modified: 2012-05-11
I want to add something like:

--------------------
New Item

at the end of the itemlist in a ComboBox and the next to the last line the "--------------------" should not be selectable, is there any way to do this?
0
Comment
Question by:Sunsales
4 Comments
 
LVL 3

Assisted Solution

by:KoenVandemoortel
KoenVandemoortel earned 332 total points
ID: 34918623
The only thing I can think of is something like this:
procedure TForm1.ComboBox1Select(Sender: TObject);
begin
if ComboBox1.Text='--------' then Combobox1.ClearSelection;
end;

Open in new window

0
 

Author Comment

by:Sunsales
ID: 34918638
Not to bad! - I will look into it.
0
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 336 total points
ID: 34919589

Use the OnCloseUp Event
procedure TForm1.ComboBox1CloseUp(Sender: TObject);
var
  Index: Integer;
begin
  Index := ComboBox1.ItemIndex;
  if (Index >= 0) and (Pos('--', ComboBox1.Items[Index]) = 1) then
    ComboBox1.ItemIndex := -1;
end;

Open in new window

0
 
LVL 19

Assisted Solution

by:Thommy
Thommy earned 332 total points
ID: 34923617
Using OnChange event...
procedure TForm1.ComboBox1Change(Sender: TObject);
var
  s:string;
begin
  s:=(sender as TComboBox).Text;
  if pos('-----',s)>0 then (sender as TComboBox).ItemIndex:=-1;
end;

Open in new window

0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

772 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