Hi, this is my first post here so I am not quite sure how to enter codes properly, but I will do my best to explain my problem anyway...
Suppose I have a new form (Form1), and I insert a combo box (ComboBox1), and the items for ComboBox1 are 1, 2, 3, and 4 (in that order).
Here is a sample of my code that I want examined and fixed:
[B]procedure[/B] TForm1.ComboBox1Change(Sender: TObject); [B]begin[/B] [B]if[/B] ComboBox1.Text<>'4' [B]then[/B] [B]begin[/B] [B]if[/B] MessageDlg('Did you mean "4"?',mtConfirmation,[mbYes,mbNo],0)=mrYes [B]then[/B] [B]begin[/B] ComboBox1.Text := '4' [B]end[/B] [B]end[/B] [B]end[/B];
To me, this code reads in English "If I don't select "4" from the combo box selection, I will receive a popup asking me if I would like to select "4", and if I click yes, then the item selected in the combo box will be "4". However, this is not what happens, in fact, nothing happens at all, the message box goes away (like it should), but the item in the combo box remains the same as what was selected.
I even tried replacing
ComboBox1.Text := '4' with
ComboBox1.Text := ComboBox1.Items which should select the fourth item in TStrings, with the fourth item of course being "4", but again nothing happens. And if you were wondering, nothing happens if I replace
ComboBox1.Text := ComboBox1.Items with
ComboBox1.Text := ComboBox1.Items.Strings either.
I read somewhere that the line
Form1.SetFocus; should fix this problem, but it doesn't, and I even tried
ComboBox1.SetFocus; to no avail.
This is of course not a replica of what I am trying to achieve, however this is a simple demonstration that could help resolve the only issue that I am having with the functionality of my program.
Any help with this issue would be very much appreciated