object ComboBox1: TComboBox Left = 8 Top = 8 Width = 121 Height = 21 ParentShowHint = False ShowHint = False TabOrder = 0 TextHint = 'Choose database...' Items.Strings = ( 'Album' 'Test' 'World')
When I ran the program the TextHint for the ComboBox did not display:
That is not what I was expecting. The Combox was the active control which negates being able to see the TextHint "Choose database..."
So I added a little piece of code to the form's onShow event.
procedure TForm1.FormShow(Sender: TObject); begin StatusBar1.SetFocus; end;
Now when I run the program right from the get-go the StatusBar componet has the focus and the ComboBox displays as intended.
Sometimes it's the small things that make all the difference!
An alternative to using the OnShow event was suggested in the comments.
Form1.ActiveControl := StatusBar1
I love Delphi!
Enjoy!
Semper Fi
Gunny Mike
You don't need FormShow for this. You need to set property Form1.ActiveControl = StatusBar1:
ReplyDelete----------
object Form1: TForm1
ActiveControl = StatusBar1
--------
But what is the meaning of this "beauty" for the user? For the user, this is uncomfortable. After starting the program, user must select ComboBox (press TAB or press hotkey or click the mouse) and then choose the database. Two actions instead of one.
Thank you for your comment. I didn't even think about using the ActiveControl property. I was simply trying to streamline the GUI by not having to add a Label or StaticText element to the form. I feel that using the TextHint provides just enough help to make it intuitive.
DeleteI prefer adding a first option with the hint text, and make it the default value
ReplyDeleteThat way you have what you are looking for, and can have it focused