Is there a way to disable being able to type any value into a combo box, in other words restrict it to only the items I tell it to?
At the moment , if I have Item1 item2 item3 in the drop down, I can type UYIUYIUY or anything in the box.
Combo Box disable manual entry
Moderators: Dorian (MJT support), JRL
Set the ComboBox style to either csOwnerDrawFixed or csDropDownList
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Left = 247
Top = 96
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 111
ClientWidth = 208
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSComboBox1: tMSComboBox
Left = 15
Top = 7
Width = 145
Height = 21
Style = csDropDownList
ItemHeight = 13
TabOrder = 0
Items.Strings = (
'Option 1'
'Option 2'
'Option 3'
'Option 4'
'Option 5'
'Option 6')
ListText = 'Option 1'#13#10'Option 2'#13#10'Option 3'#13#10'Option 4'#13#10'Option 5'#13#10'Option 6'#13#10
end
object MSComboBox2: tMSComboBox
Left = 16
Top = 48
Width = 145
Height = 19
Style = csOwnerDrawFixed
ItemHeight = 13
TabOrder = 9
Items.Strings = (
'Option 1'
'Option 2'
'Option 3'
'Option 4'
'Option 5'
'Option 6')
ListText = 'Option 1'#13#10'Option 2'#13#10'Option 3'#13#10'Option 4'#13#10'Option 5'#13#10'Option 6'#13#10
end
end
EndDialog>Dialog1
Show>Dialog1,r
This will focus edit1 when you select a ComboBox Option.
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Left = 659
Top = 121
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 111
ClientWidth = 208
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSComboBox1: tMSComboBox
Left = 15
Top = 7
Width = 145
Height = 21
Style = csDropDownList
ItemHeight = 13
TabOrder = 0
Items.Strings = (
'Option 1'
'Option 2'
'Option 3'
'Option 4'
'Option 5'
'Option 6')
ListText = 'Option 1'#13#10'Option 2'#13#10'Option 3'#13#10'Option 4'#13#10'Option 5'#13#10'Option 6'#13#10
end
object Edit1: TEdit
Left = 16
Top = 40
Width = 145
Height = 21
TabOrder = 9
Text = 'Edit1'
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,MSComboBox1,OnSelect,FocusEdit1
Show>Dialog1,r
SRT>FocusEdit1
SetDialogObjectFocus>Dialog1,Edit1
END>FocusEdit1