ComboBox.ItemIndex

How can i do that below proc.

SearchText:='All';

if searchText exists in ComboBox1 then
Show searchtext in combobox

else
begin
ComboBox1.Items.Add('searchtext')
Show searchtext in combobox
end;

Thank You
0
Melissa
1/4/2012 8:08:57 AM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

3 Replies
2733 Views

Similar Articles

[PageSpeed] 38

Melissa Torn wrote:

> How can i do that below proc.
> 
> SearchText:='All';
> 
> if searchText exists in ComboBox1 then
> Show searchtext in combobox
> 
> else
> begin
> ComboBox1.Items.Add('searchtext')
> Show searchtext in combobox
> end;

ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(searchText);
if(ComboBox1.ItemIndex = -1)then begin
   ComboBox1.ItemIndex := ComboBox1.Items.Add(searchText);
end;


HTH
ain
0
Ain
1/4/2012 8:24:57 AM
Thank you so much Ain,

But you dont search 
if searchtext exists or not in the combobox ?
your code   if(ComboBox1.ItemIndex = -1)then
means if anything exists in combobox ?? 

I first need if searchtext exists in combobox
or not,  if exists then select the searchtext in combobox
if not exist i'll add it into the combobox and select it


> {quote:title=Ain Valtin wrote:}{quote}
> Melissa Torn wrote:
> 
> > How can i do that below proc.
> > 
> > SearchText:='All';
> > 
> > if searchText exists in ComboBox1 then
> > Show searchtext in combobox
> > 
> > else
> > begin
> > ComboBox1.Items.Add('searchtext')
> > Show searchtext in combobox
> > end;
> 
> ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(searchText);
> if(ComboBox1.ItemIndex = -1)then begin
>    ComboBox1.ItemIndex := ComboBox1.Items.Add(searchText);
> end;
> 
> 
> HTH
> ain
1
Melissa
1/4/2012 8:55:10 AM
Melissa Torn wrote:

> But you dont search 
> if searchtext exists or not in the combobox ?

It does - the "ComboBox1.Items.IndexOf(searchText)" statement search
the items list for "searchText" and returns it's index, if there is no
match then the return value is "-1".


> your code   if(ComboBox1.ItemIndex = -1)then
> means if anything exists in combobox ?? 

In this case it means "if there wasn't matching item". The ItemIndex -1
means that no item is selected.


ain
0
Ain
1/4/2012 9:07:58 AM
Reply:

Similar Artilces:

What generals generally do
Reading a McChrystal thread elsewhere, I came across someone quoting a US general http://en.wikipedia.org/wiki/Smedley_Butler > I spent 33 years and four months in active military service and > during that period I spent most of my time as a high class thug for > Big Business, for Wall Street and the bankers. In short, I was a > racketeer, a gangster for capitalism. I helped make Mexico and > especially Tampico safe for American oil interests in 1914. I helped > make Haiti and Cuba a decent place for the National City Bank boys to > collect revenues in. I ...

delphi.general
Sorry if this is "out of topic"! but since some days ago I can't read the group *embarcadero.public.delphi.language.delphi.general* Does anybody know if there's something wrong with it? Or maybe is my reader? (Thunderbird) I get this messagge when I try to read the latest messages: Error! newsgroup server responded:no such article found Perhaps the article has expired <692702@forums.embarcadero.com> (33145) Click here to remove all expired articles sergio wrote: > Sorry if this is "out of topic"! but since some days ago I can'...

delphi.general Timer
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_202d5.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" For Paolo Valle --JivePart=_202d5.zeB8CwDOH5aMJzMl Content-Type: application/octet-stream; name="SubroutineTimer.pas" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="SubroutineTimer.pas" dW5pdCBTdWJyb3V0aW5lVGltZXI7DQoNCmludGVyZmFjZQ0KDQpwcm9jZWR1cmUgU3RhcnRTdWJy b3V0aW5lVGltZXI7DQpmdW5jdGlvbiBHZXRTdWJSb...

Delphi and Delphi for .Net
It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. I would like to know is it true all .Net application is slower than Win32 native applicaiton or it is Delphi for .Net only. Your information is great appreciated, Inung On 2011-06-21 18:20:17 +0100, Inung Huang said: > It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. > I would like to know is it true all .Net application is slower than > Win32 native applicaiton or it is Delphi for .Net only. If you are only running the code in the application once then, yes, yo...

Firemonkey FM2 Combobox
I'm trying to essentially "blank out" a combox. I can set it's ItemIndex to -1 (even though that is the default value). It will let me set the ItemIndex to another value. How else can I blank out the combobox? > {quote:title=Joey Hickey wrote:}{quote} > I'm trying to essentially "blank out" a combox. I can set it's ItemIndex to -1 (even though that is the default value). It will let me set the ItemIndex to another value. How else can I blank out the combobox? What do you mean by 'blank out'? From an end user point of view or from a programming point of view? Is it adequate just clear (i.e. empty) the Items? -- MonkeyStyler FireMonkey style designer http://bit.ly/PzxKyI Embarcadero MVP > {quote:title=Mike Sutton wrote:}{quote} > > {quote:title=Joey Hickey wrote:}{quote} > > I'm trying to essentially "blank out" a combox. I can set it's ItemIndex to -1 (even though that is the default value). It will let me set the ItemIndex to another value. How else can I blank out the combobox? > > What do you mean by 'blank out'? From an end user point of view or from a programming point of view? Is it adequate just clear (i.e. empty) the Items? > > -- > MonkeyStyler FireMonkey style designer http://bit.ly/PzxKyI > Embarcadero MVP OK. I have to comboxes. The first combobox determines what I display in the second box. So, say I choose "SPOR...

EVarriantTypeCast error delphi language general
I uploaded above subject to the attachment space.with test.zip. If somebody coul have a look at the test i prepared. Since overall QuickReport does work, i could not guess what is going on here. Thanks in advance to have a look at the attached test i made and hopefully somebody can find the issue. Regards. Lieven Hi xxx, If nothing works, it could mean that somewhere a mistake was made.lol. For the uploaded to public attachment test.zip solution below. Regards Lieven {Sql code} QryPtDat1.Sql.Clear; QryPtDat1.Sql.Add('SELECT D."Names", ...

General bootstrap questions: Delphi 7, pascal
Hi, This might be a bit inchoherant. I am sorry of that is the case but I have inherited a collection of languishing Delphi Projects in Pascal. I do not know Pascal and this is nearly my into to Delphi. Delphi 7 is running in a Windows XP VirtualMachine instance. The project in question uses several third party libraries / tools. Basically, I don't know where to start so I'll start at the beginning and hope you guys can help. I first inherited these projects almost two years ago. For the most part they work. There is one project, however, that needs to have a few "mag...

borland.public.delphi.database.general not fond
Hello. My problem is I am trying to connect to a newsgroup that I have configured in Outlook Express 6, under Windows XP and appears this as follows mistake : 411 Group borland.public.delphi.database.general not found. Setup: Count: newsgroups.borland.com Server: newsgroups.borland.com Protocol: NNTP Port: 119 Security (SSL): 0 Error Number: 411 Code: 800ccca5 With the newsgroup of Newsgroups.borland.com before it could enter the group borland.public.delphi.database.general, This is for all groups that begin with borland. I hope you can hel...

Delphi 2009/2010 Port of ComboBox Plus
I have an old project using the free ComboBox Plus (AKA Combo Plus or ComboBoxPlus) component available from http://www.o2a.com/cbplus.htm. It supports a multi-column dropdown, an unbound mode, and incremental search. I'm leaning toward replacing it with another more modern component, since it hasn't been updated/maintained for several years. I might keep it in this project for the moment if someone knows of a port to Delphi 2009/2010. Has anyone seen or done such a port? I tried to do a quick port myself and got it compiling, but it does custom memory management and ...

borland.public.delphi.database.general not fond #2
Hello. My problem is I am trying to connect to a newsgroup that I have configured in Outlook Express 6, under Windows XP and appears this as follows mistake : 411 Group borland.public.delphi.database.general not found. Setup: Count: newsgroups.borland.com Server: newsgroups.borland.com Protocol: NNTP Port: 119 Security (SSL): 0 Error Number: 411 Code: 800ccca5 With the newsgroup of Newsgroups.borland.com before it could enter the group borland.public.delphi.database.general, This is for all groups that begin with borland. I hope you can hel...

General question on the concept of integer handling in Delphi 2009
I found in system.pas new names "NativeInt" and "NativeUInt". According to all computer languages worldwide, Integer (and Cardinal) is *already* a native integer that represents the CPU register for best performance etc... What will happen in Delphi 2010 Win64 ??? I don't want to change Integer to NativeInt in my code thousand times to get adequate performance. > {quote:title=Ralf Stocker wrote:}{quote} > I found in system.pas new names "NativeInt" and "NativeUInt". Interesting. > According to all computer languages wor...

Delphi component for computing general linear mixed models ??
Are there any statistical software available for Delphi for computing General linear mixed models so that having a data sampler and analyser also may run statistics directly on group of humans observed pr minute basis that should be compared together ?? For you old-timers here is a hint as to what the subject is about: http://www.google.com/search?hl=en&q=%22General+linear+mixed+models%22 --JohnH Have you looked at http://www.dewresearch.com/ which has some useful code for that sort of thing? /Matthew Jones/ Alf Christophersen wrote: > Are there any statistical softw...

A general question about supporting offline databases
I am a bit of a newbie with Delphi databases, we've been using Delphi for 15 years but we have always used a proprietary binary data format. We now want to switch to an SQL file format. For now we're working with SQLITE, so the Java and C# guys in our shop can read the file too. We have all the latest tools now, XE5 with FireDAC, Datasnap, REST etc. I am very, very impressed with what we can do now. Currently, we have a Delphi desktop app that controls the data file, and use XMLRPC calls from the clients to send and receive transactions. We have what we call a "refresh&...

SEPA components for Delphi with Source Code (Delphi 5
Hi all, in the european union change next year the Bankingformat to the SEPA Format. All peoples and companies must change the bankingssoftware and the costumer data form acountnummers in the new IBAN and BIC numbers. See: http://www.arma-it.de/shop/artikelueber.php?wgruppeid=211&wgruppe_offen=211 Functions: - generate SEPA XML'S - Calc IBAN - BIC Database (DE,AT and CH) Questions: vertrieb@arma-it.de PS: Bankinssoftware for Develpoers (Germany only) http://www.arma-it.de/shop/artikelueber.php?wgruppeid=212&wgruppe_offen=212 El 26/10/13 21:38, A...

Delphi for PHP or Delphi PRISM
Hi, I have the opportunity to develop a web-based library management system. Nothing fancy, just being able to do the usual CRUD stuff for books and provide a search facility. Borrowing is to be done via an email request to the library admin who then sends out the book(s). Since both Delphi for PHP and Delphi PRISM will enable me to develop the app, which one will allow me to deliver it in less time and also increase (even how small) my marketability as a web developer? Thanks. Phillip Flores Phillip Flores wrote: > Hi, > > I have the opportunity to develop a...

Delphi 5 to Delphi XE4
Thinking about making the conversion. Of course we have numerous components such as: TurboPower AsyncPro, TurboPower Orpheus ICS2 Synactis All-In-The-Box. You guys have any advice as to the effort and time it may possibly take. It is a large application, several hundred thousand lines. And that's what happens when using third party components, a lot of extra work. I have been burned a few times. I now minimize the use to a few well known suppliers, like TMS. I have "banned" a lot of other components. Regards, Ole > > Thinking about making the conver...

Delphi 5 to Delphi 6 and up
Dear List, Trying to add 7Zip compression support to my delphi application. I am using the ported 7Zip sdk (see their website, they have a link). I am stumped on how to rewrite a single function: function ReverseDecode(var Models: array of SmallInt; ....): ..... where the input is mostly a fixed size array of SmallInt. This code perfectly compiles and functions in Delphi 6 and up, but in Delphi 5 I get the error: There is no overloaded version of 'ReverseDecode' that can be called with these arguments And obviously, the input (fixed) isn't the same as the param definition (dynamic sized). However, my question is just as obvious: How do I rewrite this function so it will behave correctly in Delphi 5? (If this is even possible) I hope I don't have to overload it to something like: function ReverseDecode(var Models: array[0..xxx] of SmallInt....... Thanks in advance for any assistance, Rory Rory Slegtenhorst wrote: > Dear List, > > Trying to add 7Zip compression support to my delphi application. > I am using the ported 7Zip sdk (see their website, they have a link). > > I am stumped on how to rewrite a single function: > > function ReverseDecode(var Models: array of SmallInt; ....): ..... > > where the input is mostly a fixed size array of SmallInt. > This code perfectly compiles and functions in Delphi 6 and up, but in > Delphi 5 I get the error: There is no overloaded version...

Delphi 4 to Delphi 2009
Hello, Thanks to all who answered my previous question. That was a great help. And atlast our client agreed to upgrade our delphi version from 4 to Delphi 2009. *Sigh*. But before that, I need to give the estimation and cost regarding the migration to delphi 2009. Can anyone tell me is there any tool to migrate from delphi 4 to delphi 2009 or just I need to compile our Delphi 4 application in Delphi 2009. I have read from the delphi 2009 feature matrix that Delphi 1 through Delphi 2007 import is possible in delphi 2009. But i am not that sure considering the size of our application. ...

Delphi 7 to Delphi XE
Have been using Delphi 7 for many moons ( have got later versions but never upgraded to ) My first problem is: Component Palette. in XE it is a small toolbar docked in top right in Delphi 7 it gives a large view of all the components. I am struggling to be able to cope/access my components.in Delphi XE. Can I make the component pallette tool bar the same size as Delphi 7, or is there a fast way to view/choose all available components in XE, that I have not spotted yet? Kind Regards, Robert. Hi, What I know is that in Delphi 2010 and XE you can choose between t...

Delphi XE / Delphi 2010
Hello! I noticed that Embarcadero® Delphi® 2010 Version is not on the list of products on Embarcadero page. Or is it still possible to buy it? Will RAD Studio XE compile programs written in Delphi 2010 without problems.? Thanks. Am 13.09.2010 09:04, schrieb Petra Nemec: > Will RAD Studio XE compile programs written in Delphi 2010 without problems.? As always you will probably have to recreate the projects as the import is still a bit -- special. Christian Hello! Does anybody know if it is still possible to get a Delphi2010 trial version (if yes where)? ...

How to free an integer object stored with text in a combobox (delphi 2009)?
Please can someone clear up my confusion. In database appliocations I frequently store an integer primary key along with text in a combobox. eg {code} ComboCustomer.Items.AddObject(custname,TObject(custID)); {code} Qn. Doing it like that do I need to do anything special to free the CustID objects when I close or destroy the form, or is that only needed when I create objects separately eg {code} MyKey := TObject.Create(CustID); ComboCustomer.AddItem(custname', MyKey ) ; {code} I ask this as I am getting access violations using the code commonly found o...

Firefox, combobox (and others), display issue and general working issue
Hi I am building a site using ASP.NET 3.5. I have on there a combobox which on IE works fine, but on Firefox, is only displaying the last value, and when I click the (oversize) down arrow, the combo expands but displays black  Having a problem with one or two other controls but any ideas what the problem might be? This is on Firefox 3.0.1 but other versions as well Thanks Why don't you post some of the code or markup and then maybe someone can help you. NC...   Actually, while copying and pasting the code I think I have found the problem. Seems Firefox and the Ajax Toolkit rounded edges are the problem! I have a combo that doesnt have this implemented yet and it works fine. Controls with the rounded edges dont! Sorry, will raise with the Ajax Toolkit folks Thanks...

Delphi 4 to Delphi 2007
Hello, I will have to port a D4 application (with source) to D2007. what kind of problem could I face ? I will have to go to customer site tommorow to analyse its source code to quote the work, what should I care of to hestimate the porting time ? Thanks John Terry wrote: > Hello, > I will have to port a D4 application (with source) to D2007. > what kind of problem could I face ? > I will have to go to customer site tommorow to analyse its source code > to quote the work, what should I care of to hestimate the porting time ? You can probably do it by just changi...

Delphi 5 To Delphi 2009
I upgraded to Delphi 2009 from D5. The install says I can install Delphi and/or C++. Delphi installed OK but I see nothing of C++. What am I missing or does my upgrade not include C++? Thanks It depends on what you bought. If you bought Delphi 2009 only, that's what you get. If you bought Delphi 2009 and C++ Builder 2009 you get both. My guess is you got Delphi 2009 only. The simplest way to verify is look your invoice - it should say I would think. You could also go to members.embarcadero.com, login, then click on my registered products. There will be a textual description of...

Web resources about - ComboBox.ItemIndex - embarcadero.delphi.general

Juhani Lehtimäki – Google+
Juhani Lehtimäki - Android developer, design fan and author of Smashing Android UI book, co-creator of Lands of Ruin. - Head of Android development ...

Creating a unique ListView layout using cell-spanning
... defaultSize: { width: 100, height: 100 } }; // Item info function that returns the size of a cell spanning item function myItemInfo(itemIndex) ...

Maor's Blog
Maor David's Blog - A blog by Maor David specializes in dot net ( .NET) framework, posts about .net, asp.net, c#, ajax. http://blog.maordavid.com ...

XBot scripting
List of methods for developing scripts in XBot.

Fully Editable Datagrid - Pale Musings
This is the text from an article I wrote back in April of 2003 and had published on the original DotNetJunkies site. After my recent change in ...

jQuery and WinJS working together in Windows Store apps
... ListView with the following code: // Get the data for the selected item in the list view. function getItem(evt) { var index = evt.detail.itemIndex, ...

Resources last updated: 3/2/2016 4:05:24 PM