Jump to content

UniDBCombobox force dropdown/close


dkeene

Recommended Posts

Hi

Is there a way to PROGRAMMATICALLY make a unicombobox to dropdown? I am trying to decrease the number of necessary actions for use to select something based on the value of the edit box.

I tried this in the OnChange method:

procedure TfmTableEdit.UniComboBoxChange(Sender: TObject);
var
   MySQL: String;
   MyTest: String;
begin
  //
   //Populate the combo dropdown

   //drop down the combo listbox
   UniSession.AddJS(TUniDBComboBox(Sender).JSName + '.expand();');   //***************here
   
end;

This approach doesn't seem to work. any suggestions?

Thank you

Doug

Link to comment
Share on other sites

I wish to make the combobox dropdown OPEN without asking the user to click the traditional button. So, when user types a few letters in the edit box, i query a database to populate the combobox items. then I want the combobox to OPEN to present user's choices. So i need a way to OPEN the combobox programatically

Link to comment
Share on other sites

1 hour ago, dkeene said:

I wish to make the combobox dropdown OPEN without asking the user to click the traditional button. So, when user types a few letters in the edit box, i query a database to populate the combobox items. then I want the combobox to OPEN to present user's choices. So i need a way to OPEN the combobox programatically

I haven't looked yet, but seems you will always have a list expanded after collapse. You should use conditions to expand...

Link to comment
Share on other sites

1 hour ago, dkeene said:

This approach doesn't seem to work. any suggestions?

 

13 minutes ago, Sherzod said:

but seems you will always have a list expanded after collapse

procedure TMainForm.UniComboBox1Change(Sender: TObject);
begin
  UniComboBox1.Expand;
end;

 

Link to comment
Share on other sites

It seems that if user is typing in the edit part of the combobox, and the list box is not showing, UniComboBox1.Expand does not drop down the listbox. 

In the images, user enters the blank combobox which has no Items in the dropdown. (snap123.png)

user types asp (snap124.png)

program queries medication database: select medication from medication_table where medication like "%asp%" -- this returns some result set.

i want the dropdown to OPEN with this list without user to have to click the dropdown button. as it appears in (snap129.png)

snap123.png

snap124.png

snap129.png

Link to comment
Share on other sites

my question is not how to populate the listbox, but looking for the functionality such as:

Delphi ComboBox.Autodropdown:

         

When AutoDropDown is true, the combo box automatically drops down its list when the user starts typing a string while the combo box has focus. 

When AutoDropDown is false, the user must explicitly use the drop-down button to drop down the combo box list. 

 

How can I achieve this functionality with UniComboBox?

 

Link to comment
Share on other sites

Here is example on simple form.

 

procedure TForm1.ComboBox1Change(Sender: TObject);
var
   i: integer;
begin
   for i := 0 to 3 do
   begin
      ComboBox1.Items.Add(IntToStr(random(200))) ;

   end;
end;

procedure TForm1.FormCreate(Sender: TObject);

begin
   ComboBox1.AutoDropDown:=True;
end;

 

The point of this demo is: combobox is closed. On typing something, the dropdown  list changes but automatically pops down. That is all that i want -- the autoDropDown.

Link to comment
Share on other sites

20 hours ago, dkeene said:

The point of this demo is: combobox is closed. On typing something, the dropdown  list changes but automatically pops down. That is all that i want -- the autoDropDown.

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniComboBox1.MinQueryLength := 100;

end;
procedure TMainForm.UniComboBox1Change(Sender: TObject);
var
  I: integer;
begin
   for I := 0 to 3 do
   begin
     UniComboBox1.Items.Add(IntToStr(random(200))) ;
   end;

   (Sender as TUniComboBox).JSInterface.JSCallDefer('expand', [], 200);
end;

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...