-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
Delphi To/From
To/FromCODEGuides
Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

September Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyPascal and Delphi Coding BoardDelphi Internet Solutions Topic   Print This     

Problem Using the TIWComboBox

Problem Using the TIWComboBox in Delphi Internet Solutions topic (part of our Pascal and Delphi Coding group).

Quick Search: Problem   TIWComboBox   Problem Using   Problem Using TIWComboBox  
marge
-- UNK

Hi everyone, I'm not sure where I should exactly put this post, so I will probably try a couple of places. 

Anyway, I am new to the intraweb.  I am using Delphi2006 and want to convert a system i had created to the intraweb.  I have no problem when using the regular combo box, but I'm trying to use the TIWComboBox and having a horrible time to get it to work!

It will not clear and I've thought I've tried everything.  I can't get it to retrieve the information from the database unless I use:

 IWCombobox.NoSelectionText         := UserSession.DS.Fields[1].AsString;

I cannot find alot of information on NoSelectionText.  Even then, it seems that this doesn't work all of the time and I don't know why.   I'm totally confused on this component and hope someone can help.  I've wasted too much time on this.  Can anyone even suggest a good site that would help?

Any help is greatly appreciated!  Thanks!!

 Posted 18 years ago (Thread Starter)
Comment Quote
About marge
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #13106, 2 replies
Thread Started 11/6/2008 10:13:22 AM
View Counter=6934
Last Reply Posted 12/8/2008 7:34:34 AM)
Location=-- UNK 
Joined=18 years ago   MB Posts=3  
Wes Peterson
Prestwood IT
Prestwood IT office in Citrus Heights, CA

Hi Marge,

First thing I should say is that I'm not an IW user. (I have nothing against it, just haven't gotten around to using it).

I checked IW help for the vesion that ships Delphi 7 (I didn't install IW with my D2006).  It looks like two IW components will behave pretty much (but not exatly) like their VCL counterparts.

TIWComboBox  has an Items property.  I think this is what's going to interest you.

To clear the combobox, try:

MyComboBox.Items.Clear;

To populate the combobox try:

MyComboBox.Items.Add('stringValue);

Performance tip:  After clearing, and before populating, set the Sorted property False.  Add your items, and, when finished, set Sorted to True.

Forcing an items list (TStrings) to sort while inserting (Sorted := True) is expensive in terms of machine cycles.  Every addition forces the TStrings to resort themselves.

Saving the sort operation for last means the Items list has to sort itself only once.  You'd be amazed at the difference in performance when the number of items is large.

DB Tip #1: When populating a ComboBox from a database, it's often useful to store not only the item name, but also its primary key value.  This is frequently an autoinc (integer) value.  If it is, I use this trick:

MyComboBox.Items.AddObject('ItemName', Pointer(PKvalue));

The Object property of lists (TStrings) holds a pointer, whis is the reason for the cast, above).

To retrieve the primary key, you do the revese cast: Integer(object);

DB Tip #2: Have you looked at TIWDBComboBox? It appears to be analagous to the VCL TDBComboBox, complete with properties for DataSource and Field. It might actually be easier to use - and save you some manual coding.

If the above doesn't help, there are at least two potentially useful resources:

http://www.tamaracka.com

Tamarack is the maker of the Rubicon add-on for full-text indexing databases  At the URL, above, they maintain an archive of Borland (and related 3rd party) newsgroup posts - as a way to show off Rubicon.

I just did a search, there, on "TIWComboBox," and it returned 170 articles!

You don't mention whether you're using the bundled version of IntraWeb, or the full-blown commecial one.  If the latter, you're entitled to some support from Atozed, makers of IntraWeb.

If the bundled version, well, support is limited to FAQs on the Atozed site, and Atozed newsgroups and Chat.

See "Peer Support," here:

http://www.atozed.com/IntraWeb/Support/Peer.EN.aspx

Hope that helps.

Wes Peterson
Senior Software Engineer
Prestwood IT Solutions
http://www.prestwood.com

 Posted 18 years ago
Comment Quote
About Wes Peterson
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Wes Peterson

Wes Peterson is a Senior Programmer Analyst with Prestwood IT Solutions where he develops custom Windows software and custom websites using .Net and Delphi. When Wes is not coding for clients, he participates in this online community. Prior to his 10-year love-affair with Delphi, he worked with several other tools and databases. Currently he specializes in VS.Net using C# and VB.Net. To Wes, the .NET revolution is as exciting as the birth of Delphi.


Post ID #13155 (Level 1.1)  Reply to 13106
Thread Started 12/7/2008 10:46:45 AM
Location=Prestwood IT office in Citrus Heights, CA 
Joined=22 years ago   MB Posts=158   KB Posts=163   KB Comments=34   BLOG, Topics=20  
Most Recent Post
marge
-- UNK

Thank you so much for your help!  What I ended up doing was this:

 IWCombobox.NoSelectionText         := '';
 IWCombobox.Items.Text                   := IWCombobox.NoSelectionText;
 IWCombobox.Clear;
Load_Codes;

Load_Codes consists of this coding:

 IWCombobox.Items.Clear;
 UserSession.DS.Close;
 UserSession.DS.SQL.Clear;
 UserSession.DS.SQL.Add( 'Select Distinct(Code), Sub_Code, Description From BC_CODE' );
 UserSession.DS.SQL.Add( 'Order by Code' );
 UserSession.DS.Open;
 Count     := UserSession.DS.CountQueryHits;
 SetLength(Array,Count);
 UserSession.DS.First;
 For I := 0 To Count - 1 Do
 Begin
         Array[I] := UserSession.DSCode.AsString +' '+ UserSession.DSSub_Code.AsString +' '+
                             UserSession.DSDescription.AsString;
         IWCombobox.Items.Add(Array[I]);
         UserSession.DS.Next;
      End;
      UserSession.DS.Close;

Why I had to put in those 3 lines up above in order to clear the combo box is beyond me.  I thought that was crazy.  I was doing trial and error and finally got the box to clear using that code.

I will look into the http://www.tamaracka.com site further.   Thanks!!

 Posted 18 years ago (Thread Starter)
Comment Quote
About marge
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #13157 (Level 1.2)  Reply to 13106
Reply Posted 12/8/2008 7:34:34 AM
Location=-- UNK 
Joined=18 years ago   MB Posts=3  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1131A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #13106 Counter
6934
Since 11/6/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2026 Prestwood IT Solutions.   [Security & Privacy]