Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

tComboBox with unselecteble items

Posted on 2011-02-17
4
Medium Priority
?
325 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 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

704 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