Solved

How can I automate the dropdown of for example a combobox ?

Posted on 2001-07-18
23
256 Views
Last Modified: 2010-04-06
How can an onclick event handler of for example a button cause a combobox to drop down ?
Or what method or technique can be used to drop down a combobox without clicking on the combobox nor the combobox drop-down button ?
0
Comment
Question by:oowolven
  • 6
  • 6
  • 5
  • +5
23 Comments
 
LVL 4

Expert Comment

by:jsweby
ID: 6293208
Set the ComboBox.DroppedDown property to True to manually drop the list, set it to False to close the list.

J.
0
 

Author Comment

by:oowolven
ID: 6293259
The problem is that I'm not using a regular combo-box but a derived one that has not the 'droppeddown' property.  I have to simulate the event that the user clicked on the dropped down button, but I don't know how to do this.  When I call the the onclick event of this particular combobox, it doesn't drop down.  If anyone can specify how to call an event that makes a normal and hopefully also my combobox drop down.
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6293281
The OnClick event isn't designed to make the Combobox drop down, it is a common TControl event that handles what to do when the user simply clicks on that control. The point of the DroppedDown property is that this is the designed way to manually drop and close the combobox's list. I cannot understand why your deriviative of the TCustomComboBox doesn't have this property.

J.
0
 

Author Comment

by:oowolven
ID: 6293299
I'm using a specific type of stringgrid where after its specific onclickcell-event normally the associated combobox droppes down.  So when I'm running the program and I click on the specific cell, the combobox drops, but when I call this onclickcell-event it refuses to drop.  Here follows a formal description of this event:

TtsClickPosition  = (cpHeading, cpRowBar, cpUpperLeft, cpCell, cpNone);
TtsClickCellEvent = procedure (Sender: TObject; DataColDown, DataRowDown, DataColUp, DataRowUp: Longint; DownPos, UpPos: TtsClickPosition) of object;
property OnClickCell: TtsClickCellEvent;
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6293336
What do the DataColDown, DataRowDown, DataColUp & DataRowUp parameters do?

J.
0
 
LVL 21

Expert Comment

by:gemarti
ID: 6293346
Maybe this is to simple a solution but this works:

   if ComboBox1.Focused = false then
     begin
       ComboBox1.SetFocus;
       ComboBox1.DroppedDown := True;
     end;
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6293360
gemarti, we've already discussed that the comboboxes in question don't have the DroppedDown property.

J.
0
 

Author Comment

by:oowolven
ID: 6293451
DataColDown, DataRowDown, DataColUp & DataRowUp parameters do?

Datacoldown identifies the column number of the cell in the grid where the left mousebutton was pressed.
Datarowdown identifies the row number of the cell in the grid where the left mousebutton was pressed.
Datacolup and datarowup do the same but simply for where the left mousebutton was released.
For example:   OnClickCell(tsg,8,2,8,2,cpnone,cpnone) return focus to the cell in the grid (tsg) at column position 8, row position 2, which is comboenabled but this onclickevent does not trigger the combodropdown event associated with the cell.


0
 
LVL 17

Expert Comment

by:geobul
ID: 6293464
Hi,
Try this:

procedure SetDroppedDown(cb: TComboBox; Value: Boolean);
var
  R: TRect;
begin
  SendMessage(cb.Handle, CB_SHOWDROPDOWN, Longint(Value), 0);
  R := cb.ClientRect;
  InvalidateRect(cb.Handle, @R, True);
end;

...
SetDroppedDown(ComboBox1, true);

Regards, Geo
0
 
LVL 21

Expert Comment

by:gemarti
ID: 6293466
Thanks. I noticed that after I posted, but I don't understand why a custom combobox does not have the attributes of it's parent. Why would you have a combobox but no DroppedDown Property? Something doesn't make sense here. Any way you guys have at it.

I made a comment I didn't propose an answer.
0
 
LVL 17

Expert Comment

by:geobul
ID: 6293477
I forgot to say:
Replace TComboBox in the definition with your type.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 4

Expert Comment

by:jsweby
ID: 6293482
gemarti, I'm asking myself the same question... Geo's solution looks interesting...

J.
0
 

Author Comment

by:oowolven
ID: 6293498
I tried the geobul suggestion, but still nothing happended,

0
 
LVL 17

Expert Comment

by:geobul
ID: 6293509
Could you post that piece of code where you are using it?

Regards, Geo
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6293510
Then I'm at a loss.
J.
0
 

Author Comment

by:oowolven
ID: 6293521
begin
                bool:=false;
               error:=108;
                messagedlg('U dient op te geven met wie u reist als passagier',mtinformation,[mbok],0);
                tsg.currentdatacol:=metwiek;
                SetDroppedDown(tsg.Combo.Grid, true);

                end;

This is part of a normal event, I followed the code through the debugger and it seemed ok, but on the grid (tsg) itself, nothing happens.
0
 
LVL 2

Expert Comment

by:bugroger
ID: 6293606
Hi,

if your combobox drop down with MouseButtonDown then
try this

 ComboBox1.Perform(WM_LBUTTONDown, 0, MakeLParam(ComboBox1.Width - 5, 2));

if your combobox drop down with MouseButtonUp then
try this

 ComboBox1.Perform(WM_LBUTTONup, 0, MakeLParam(ComboBox1.Width - 5, 2));


GL
 Bug
0
 

Expert Comment

by:d32coder
ID: 6293608
If you have the pas of the CustomCombobox, you can add that property and recompile it.   This assumes your component is a descendent of TComboBox.


You'll see a list of 'properties' near the top of the .pas.
just add

 property DroppedDown;

Don
0
 
LVL 17

Expert Comment

by:geobul
ID: 6293639
Somethig else is happening after SetDroppedDown call and the box closes its list (like SetFocus for example).

Could you place a button on the form and test the following:

procedure TForm1.Button1Click(Sender: TObject);
begin
 SetDroppedDown(tsg.Combo.Grid, true);
end;

if it's possible.

P.S.: tsg.Combo.Grid looks strange to me. Are you sure that it is the right component?

Regards, Geo
0
 

Author Comment

by:oowolven
ID: 6293688
Still nothing works

We should'nt keep focussing on the specific combobox properties what happens in fact is the following:

The grid whit which I'm working is a descendant of the normal stringgrid,  it also offers opportunities to easily place buttons in the cells representing the celltype.  In my case one of these cells is of the combo-type, this doesn't mean that a combobox is created but that a stringgrid is created representing the features of a combobox.  With if this newly created grid and place and items are handled by the event triggered by pushing the button in the cell of the primary grid.  A secondary grid will then roll down representing different options.  So what i'm looking for is simulating the spefific mouseclick on the button on the cell of the specific cell.

tsg.combo.grid is dus de secundaire grid, a descendant of Tcustomgrid
0
 
LVL 17

Expert Comment

by:geobul
ID: 6293728
My solution won't work in this case. You better try bugroger's suggestion.

Regards, Geo
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 8703459
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

To be PAQ/Refund

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Thank you,
Russell

EE Cleanup Volunteer
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 8822159
PAQ'ed and points not refunded

PashaMod
CS Moderator @Experts Exchange
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
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

12 Experts available now in Live!

Get 1:1 Help Now