Solved

tComboBox with unselecteble items

Posted on 2011-02-17
4
322 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
[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
4 Comments
 
LVL 3

Assisted Solution

by:KoenVandemoortel
KoenVandemoortel earned 83 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 84 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 83 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi IDE crash without error message ... 7 116
How to renew a Delphi rad-studio licence? 5 76
How to debug For loops? 3 60
tidtcpserver connection lost handle 2 109
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 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