Solved

tComboBox with unselecteble items

Posted on 2011-02-17
4
317 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 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:
ewangoya 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now