Search   Contact   Home    
ProductsSupportDownloadsSpeech TechnologyLinksCustomer CommentsFree Stuff

Table of ContentsAnswers to Frequently Asked Questions for the ComboBox Plus Components

  1. How do I use the TDBLookupComboPlus component to navigate a table?
  2. How do I force the case to upper case in the LookupComboPlus component as the user types?
  3. How do I get TDBLookupComboPlus to do case insensitive incremental searches?
  4. I've downloaded your "How to put controls into a grid demo" and I can't make it work with TDBLookupComboPlus. What's the problem?
  5. I have two forms. Each form has a TDBLookupComboPlus component that accesses the same data source. The datasource is in the main form. At run time I assign the DataSource to the LookupComboBox in form two in the forms onCreate event. The problem is that when I drop the combobox list the second time a blank row appears at the end of the list. If the user selects this blank row then the application GPFs. What do I do?
  6. I've implemented the onNewLookupRec event but after displaying the new record dialog, like in the demo, when the dialog box disappears and the next field has the focus I've lost my cursor. What should I do?
  7. I'm adding lots of rows to the TDBComboboxPlus (over 2000) and it takes a number of seconds for it to load. Is there anyway I can speed this up.
  8. I have a TDBLookupComboPlus control with the TDBText next to it. I want the Text control to display one of the fields from my lookup table as long as the incremental search successfully finds a match. If no match is found then I want the text to display nothing.
  9. How can I make a case insensitive search work with TDBLookupComboPlus? It works OK now except that when you press the first small letter it goes to the end. Heres some info on case insensitive indexes from Robert Schieck (TeamB)

If you can't find the answer to you question here then drop us a line at 75664.1224@compuserve.com. We always like a good question.

How do I use the TDBLookupComboPlus component to navigate a table?

You can use the TDBLookupComboPlus component as a convenient way to navigate records in a table here's how.

First you drop a TDBLookupComboPlus component on the form. Set it's style property to csIncSearch (csIncEditSrch will not work because typing entries that are not in the table is not allowed in searchs, in fact, trying to do so will crash the application). Next assign the LookupSource property to the data source of the table you want to search. Do not assign a value to the components DataSource property or DataField property. At this point you could run the application and moving through the list will change the current record. If you have a navigator component attached to the same table you will notice that clicking on the forward and back buttons will not change the value displayed in the TDBLookupComboPlus if you want this behavior you must define the onDataChange event for the TDataSource. component The TDataSource's onDataChange event should look something like this.

procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
begin
{} DBLookupComboPlus1.text := Table1.FieldbyName('Name').Asstring;
end;

This forces the edit portion of the LookupComboPlus to display the information of the current record. This step is optional. Another optional step is if you want the edit portion of the LookupComboPlus to display information when the form is first displayed. To do this you must define the form's onActivate event. Like the event above it should read something like

procedure TForm1.FormActivate(Sender: TObject);
begin
{} DBLookupComboPlus1.text := Junk2.FieldbyName('Location').Asstring;
end;

Back to Top

How do I force the case to upper case in the LookupComboPlus component as the user types?

It's easy just define the onKeyPress event for the LookupComboPlus component like so.

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
{} Key := upCase(key);
end;

Note that this is not a solution for case sensitive indexes.

Back to Top

How do I get TDBLookupComboPlus to do case insensitive incremental searches?

The DBLookupComboPlus itself can not by itself do case insensitive searches. The case sensitivity of a table must be implemented at the table's index level not in the control.

The ability to do case in-sensitive searches is really dependent on the types of tables you are using. Paradox tables support case insensitive indexes (see the included demos) for non-primary indexes. As do most SQL DB servers support case insensitive indexes. dBase tables do not support case insensitive indexes directly. In order to get a case insensitive search with a Dbase table you must define the index that is assigned to the component's lookupIndex property as an expression index when defining the table (with DB Desktop). In the expression index you need to force the index to uppercase. For example, lets say you have a dBase table named CONTACT that contains a field called COMPANY that you want to incrementaly search on. When defining this table you must define an expression index on COMPANY and the expression would be UPPER(CONTACT).

Back to Top

I've downloaded your "How to put controls into a grid demo" and I can't make it work with TDBLookupComboPlus. What's the problem?

The original version of GRIDDEMO.ZIP was incorrect. The fix is simple. Create and onActivate event for the main form and then copy everything that's in the form's onCreate event into the new onActivate event. Then delete everything that's in the onCreate event and recompile.

Back to Top

I have two forms. Each form has a TDBLookupComboPlus component that accesses the same data source. The datasource is in the main form. At run time I assign the DataSource to the LookupComboBox in form two in the forms onCreate event. The problem is that when I drop the combobox list the second time a blank row appears at the end of the list. If the user selects this blank row then the application GPFs. What do I do?

There appears to be a bug in Borlands TDataLink object that causes this problem. A private field named FFirstRecord is mistakenly set to 1 instead of 0 which would be correct. This causes the dropdown list to believe there is one more record than is actually available to display and makes the size of the list one record to large.

This problem does not occure if the drop down list in the combobox in the main form is dropped once prior to entering the secondary form. Dropping this list once does some initialization in the TDataLink object which is owned by the shared datasource that does not otherwise occure. The solution is to drop the list for the combobox in the main form once when the application first starts up and then to put it away imediately. The fix goes into the main form's onShow event and looks like this.

procedure TForm1.FormShow(Sender: TObject)
begin
{} LUClient.dropdown;
{} LUClient.closeup;
end;

By the way, this problem is not unique to the TDBLookupComboPlus component. It also exists in the original TDBLookupCombo component.

Back to Top

I've implemented the onNewLookupRec event but after displaying the new record dialog, like in the demo, when the dialog box disappears and the next field has the focus I've lost my cursor. What should I do?

Yes this is truly a problem and the implementation in the original demo is not 100% correct. It turns out that it is against the rules of windows (and Delphi) to display a dialog box (show message etc.) while changing focus from one control to another. For this reason the most correct thing to do is to return the focus to the combo control after the new record dialog has been displayed as in the following code.

procedure TForm1.ComboPlusSubCat4NewLookupRec(Sender: TObject;
var Cancelled: Boolean);
begin
{} Cancelled := False; {Set cancelled to false initially}
{} TableSubCat.Insert; {Start a new SubCat record}
{} TableSubCat.FieldByName('SubCatName').AsString := {and set the new name value}
{} ComboPlusSubCat4.DisplayValue;
{} SubCatDlg.ShowModal; { display the dialog box }
{} if SubCatDlg.ModalResult=mrOK then {if user pressed OK then save the new SubCat}
{} begin
{}{} TableSubCat.Post; {if user said oK then post}
{}{} {*** VERY IMPORTANT*** Now Update the Compbo's value property.
The Combo component doesn't know anything about the table that
the SubCatDlg box uses so you must tell the combo what the
SubCat number is. This will need to be done in any case where
the lookup field is different than the display field.}
{}{} ComboPlusSubCat4.Value := TableSubCat.FieldByName('SubCatNum').AsString;
{} end
{} else
{} begin
{}{} TableSubCat.Cancel;
{}{} Cancelled := True;
{} end;
{} ComboPlusSubCat4.SetFocus;
end;

Back to Top

I'm adding lots of rows to the TDBComboboxPlus (over 2000) and it takes a number of seconds for it to load. Is there anyway I can speed this up.

The addrow method uses the drop down lists add method. This add method is designed so new rows will automatically be added in the first blank row. In order to do this a search is required each time a new row is added to find the first empty row. This search takes time especially when the number of rows gets large. You can substantially speed up the time it takes to load the drop down list by assigning your data to the rows directly instead of using the addrow or add methods. To do this you must keep track of the next blank row your self. This eliminates the need for the search. For example filling the drop down list from a list box would be much faster using

For i:= 0 to ListBox1.Items.Count-1 do
{} ComboBoxPlus1.Cols[1].Strings[i] := ListBox1.Items[i];

than using

For i:= 0 to ListBox1.Items.Count-1 do
{} ComboBoxPlus1.Cols[1].Add(ListBox1.Items[i]);

Back to Top

I have a TDBLookupComboPlus control with the TDBText next to it. I want the Text control to display one of the fields from my lookup table as long as the incremental search successfully finds a match. If no match is found then I want the text to display nothing.

Try the following code

procedure TForm1.DBLookupComboPlus1AfterSearch(Sender: TObject);
var
{} I : Word;
begin
{} For I := 1 to length(DBLookupComboPlus1.Searchvalue) do
{} begin
{}{} If Upcase(DBLookupComboPlus1.Searchvalue[I]) <>
{}{} upcase(DBText1.DataSource.DataSet.FieldByName(DBText1.DataField).asString[I]) then
{}{} begin
{}{}{} DBText1.Visible := False;
{}{}{} Exit;
{}{} end;
{} end;
{} DBText1.visible := True;
end;

Back to Top

How can I make a case insensitive search work with TDBLookupComboPlus? It works OK now except that when you press the first small letter it goes to the end. Heres some info on case insensitive indexes from Robert Schieck (TeamB).

InterBase does not support case insenstive indexes. You have a couple of choices to solve this:

1) select * from customer where upper(lastname) = Upper('schieck');

This will not use an Index but will do a table scan.

2) You can store all of your names in Upper case in InterBAse and then do a

select * from customer where lastname = Upper('schieck');

3) You can create a second field called Ulastname in your database and use a trigger to put a version of the lastname into the Ulastname column all in uppercase. This takes extra room but you can then index it. You would then do a

Select * from Customer where ulastname = 'schieck';

4) I don't know if Delphi has it but if you stored all of your names with the first character of each word set to uppercase ( it us usually done by a function called proper) the you could say.

select * from customer where lastname = proper('schieck');

5) I have yet to investigate but you might be able to use an alternate collating sequence to make 'a' and 'A' the same.

Back to Top
Back to O&A Home Page

Top of Page

 

E-Mail us  
  Search | Contact | Products | Services & Support | Downloads | Speech | Links | Comments
Last updated October 20, 2005
© 1999, 2000 O&A Productions