Solved

Combo box without button on the right side

Posted on 2004-04-16
27
1,069 Views
Last Modified: 2012-05-04
I want to have combo box without button on the right side (to click on it and combo will drop down a list).

I want when user clicks on combo it droppes down.

How to do that?

I tryed to set ComboBox style to csSimple, but then I can not drop down item list from it.

Thank you.
0
Comment
Question by:Roza
  • 9
  • 7
  • 6
  • +4
27 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 10841401

Put little TPanel on top of this button
0
 
LVL 2

Author Comment

by:Roza
ID: 10841461
That won't do anything...

I wont to save on some space (with)...
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10841513
procedure TForm1.ComboBox1Enter(Sender: TObject);
begin
  ComboBox1.Style := csDropDownList;
  ComboBox1.DroppedDown := True;
end;
0
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10841528

  and OnCloseUp put this

procedure TForm1.ComboBox1CloseUp(Sender: TObject);
begin
  ComboBox1.Style := csSimple;
end;

  to go back again to csSimple style
0
 
LVL 2

Author Comment

by:Roza
ID: 10841557
That would be sollution but...

Tryed that already
-when combo box closes I can not do anything more with it. Only possibility is to exit from control and enter again.
0
 
LVL 17

Expert Comment

by:mokule
ID: 10841628
You want to save some space for another control ?
When the Combo is droppedDown or in normal state?
0
 
LVL 2

Author Comment

by:Roza
ID: 10841671
In normal state of course.

See how Ivanov G sollution works. It's ok to me. Problem is only when combo closes down. It should be clickable again.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10841702
procedure TForm1.ComboBox1CloseUp(Sender: TObject);
begin
  ComboBox1.Style := csSimple;
  // set focus on the form
  Self.SetFocus;
end;

what about this ?
0
 
LVL 17

Expert Comment

by:mokule
ID: 10841717
If this is the only problem
try this

procedure TForm1.ComboBox1CloseUp(Sender: TObject);
begin
  ComboBox1.Style := csSimple;
  ActiveControl := nil;
end;
0
 
LVL 4

Expert Comment

by:tobjectpascal
ID: 10841743
http://www.delphi32.com/vcl/965/

seems to do what you want...
0
 
LVL 2

Author Comment

by:Roza
ID: 10841939
tobjectpascal
TNX but not what I am searching for.

mokule&Ivanov_G: Focus should remain on "ComboBox".
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10842001

   put this in OnClick

       ComboBox1.Style := csDropDownList;
       ComboBox1.DroppedDown := True;

  and this OnCloseUp

       ComboBox1.Style := csSimple;
0
 
LVL 17

Expert Comment

by:mokule
ID: 10842077
Why don't You want to use my solution with TPanel.
It' simple.
Works perfectly.
If You want You can place another control so it covers some part of the TPanel.
Where is the problem, I can't see any.
0
 
LVL 2

Author Comment

by:Roza
ID: 10842095
I've tryed all of this sollutions already and then do not work. That's why I asked question here.

I have already tryed to create my own combo box from TCustomCombo, but I can not find procedure where TCustomCombo actualy paints.
Sollution is probably in way of overriding WMPaint of TComboBox and not painting button...

0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10842108

    one possible problem - use LARGE fonts and check
0
 
LVL 2

Author Comment

by:Roza
ID: 10842140
mokule: Yes it works, but...
My spare sollution is to have one TEdit and one TComboBox. Now when user enters on TEdit, TComboBox shows up and receives focus. On TComboBox OnExit again TEdit shows up...
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 10842180
The idea is bad.
The component will look like a TEdit and a user would expect TEdit behavior.
The drop down arrow is what the name says an indicaton that a drop down list is to be expected.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10842281

  my last suggestion :

procedure TForm1.ComboBox1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_DOWN then
    begin
      ComboBox1.Style       := csDropDown;
      ComboBox1.DroppedDown := True;
    end;
end;

procedure TForm1.ComboBox1CloseUp(Sender: TObject);
begin
  ComboBox1.Style := csSimple;
end;
0
 
LVL 2

Author Comment

by:Roza
ID: 10842304
robert_marquardt:
I know, but in about 80% user selects item with shortcut key.
I usualy use one with drop down arrow, but here I would like to have that space drop down arrow is using.

I use dbcombobox aligned with dbgrid columns with other edits. Dbgrid has smaller font than edits have and if I place a combo box with drop down arrow it uses 50% more space than normal edit would.
0
 
LVL 2

Author Comment

by:Roza
ID: 10842389
Hm.. some strange explanation:

>I use dbcombobox aligned with dbgrid columns with other edits. Dbgrid has smaller font than edits have and if I place a combo box with >drop down arrow it uses 50% more space than normal edit would.

I have dbgrid and on bottom of the grid some edits and combobox (used for inputs) aligned with dbgrid columns...

Sounds better I think..
0
 
LVL 17

Expert Comment

by:mokule
ID: 10842529
What about such solution

procedure TForm1.ComboBox2CloseUp(Sender: TObject);
begin
  ComboBox2.Width := 100;
end;

procedure TForm1.ComboBox2DropDown(Sender: TObject);
begin
  ComboBox2.Width := 200;
end;
0
 
LVL 2

Author Comment

by:Roza
ID: 10842581
mokule: Sorry, but I would like to use space that dropdown arrow is using for text...
0
 
LVL 17

Expert Comment

by:mokule
ID: 10842619
My last word put TPanel on dropdown arrow. It resolves everything
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 10856962
mokule: what would that help ? it's not about making that arrow invisible, it's about making that space usable for editing
placing a panel over doesn't make it usable at all ..

roza: what about using a T(DB)Edit and displaying a T(DB)ListBox under it
you can add some "automation" on the Edits OnKeyUp and OnEnter/Exit events
0
 
LVL 17

Accepted Solution

by:
mokule earned 50 total points
ID: 10857118
Lee Nover: Yes it makes it usable. Can't imagine ? Here You are.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    ComboBox1: TComboBox;
    Panel1: TPanel;
    ComboBox2: TComboBox;
    Panel2: TPanel;
    ComboBox3: TComboBox;
    Panel3: TPanel;
    ComboBox4: TComboBox;
    Panel4: TPanel;
    ComboBox5: TComboBox;
    Panel5: TPanel;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.
{----------------------------}
object Form1: TForm1
  Left = 192
  Top = 114
  Width = 602
  Height = 195
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object ComboBox1: TComboBox
    Left = 16
    Top = 24
    Width = 121
    Height = 21
    Style = csDropDownList
    ItemHeight = 13
    TabOrder = 0
    Items.Strings = (
      '1'
      '2'
      '3'
      '4'
      '5')
  end
  object Panel1: TPanel
    Left = 118
    Top = 23
    Width = 25
    Height = 25
    BevelOuter = bvNone
    TabOrder = 1
  end
  object ComboBox2: TComboBox
    Left = 120
    Top = 24
    Width = 121
    Height = 21
    Style = csDropDownList
    ItemHeight = 13
    TabOrder = 2
    Items.Strings = (
      '1'
      '2'
      '3'
      '4'
      '5')
  end
  object Panel2: TPanel
    Left = 222
    Top = 23
    Width = 25
    Height = 25
    BevelOuter = bvNone
    TabOrder = 3
  end
  object ComboBox3: TComboBox
    Left = 224
    Top = 24
    Width = 121
    Height = 21
    Style = csDropDownList
    ItemHeight = 13
    TabOrder = 4
    Items.Strings = (
      '1'
      '2'
      '3'
      '4'
      '5')
  end
  object Panel3: TPanel
    Left = 326
    Top = 23
    Width = 25
    Height = 25
    BevelOuter = bvNone
    TabOrder = 5
  end
  object ComboBox4: TComboBox
    Left = 328
    Top = 24
    Width = 121
    Height = 21
    Style = csDropDownList
    ItemHeight = 13
    TabOrder = 6
    Items.Strings = (
      '1'
      '2'
      '3'
      '4'
      '5')
  end
  object Panel4: TPanel
    Left = 430
    Top = 23
    Width = 25
    Height = 25
    BevelOuter = bvNone
    TabOrder = 7
  end
  object ComboBox5: TComboBox
    Left = 432
    Top = 24
    Width = 121
    Height = 21
    Style = csDropDownList
    ItemHeight = 13
    TabOrder = 8
    Items.Strings = (
      '1'
      '2'
      '3'
      '4'
      '5')
  end
  object Panel5: TPanel
    Left = 534
    Top = 23
    Width = 25
    Height = 25
    BevelOuter = bvNone
    TabOrder = 9
  end
end
{----------------------------}
0
 
LVL 11

Assisted Solution

by:calinutz
calinutz earned 250 total points
ID: 10858121
Place a EditBox on Top of the ComboBox and then

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
If key=VK_DOWN then
begin
ComboBox1.DroppedDown:=true;
Form1.ActiveControl:=ComboBox1;
end;
end;

procedure TForm1.ComboBox1CloseUp(Sender: TObject);
begin
Form1.ActiveControl:=Edit1;
end;
0
 
LVL 11

Expert Comment

by:calinutz
ID: 10858145
//and this also

procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
ComboBox1.DroppedDown:=true;
Form1.ActiveControl:=ComboBox1;
end;

procedure TForm1.ComboBox1CloseUp(Sender: TObject);
begin
Edit1.Text:=ComboBox1.Text;
Form1.ActiveControl:=Edit1;
end;
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
oracle global variables 4 69
Error E2158 compiling with Delphi XE10 Seattle 2 100
DBGrid or StringGrid ? 6 91
update joined tables 2 47
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 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