Solved

Combo box without button on the right side

Posted on 2004-04-16
27
1,085 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: how to send PJL commands to printer 3 109
Delphi : could not find program, '...exe' 2 192
error 1.1 400 Bad request idhttp delphi 18 147
Firemonkey allowing RTL on android 6 47
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

829 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