Board index » delphi » more questions, on creating a combobox with list boxes

more questions, on creating a combobox with list boxes

Hell-o again,

I have another question.
I want to create something like a scrollable combobox or listbox where each
string entry is also accompanied by a small combobox of it's own. This would
be sort of like a tCheckListBox component but instead of a check box, I want
a small combobox for each entry.

What I need this is to manage strings, and I want each string to have a
designation between A and F, and to let the user select the designation (vis
the small combo box) (but not change the strings themselves).

Can anyone help on this?

All my other questions are answered.

Thanks,

Gino :)

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

 

Re:more questions, on creating a combobox with list boxes


Wouldn't it be easier to use a TListBox with 7 columns (1 for the text and 6
for A/F with a checkmark in one of the A/F columns ?
You would need to set Style to lbOwnerDrawFixed and write an OnDrawItem
event that draws the text in the first column and the checkmark in one of
the following columns. In the OnMouseDown event you could determine the
column that was clicked and modify the checkmark position accordingly.

Quote
"Gino Costa" <gco...@beld.net> wrote in message

news:3ba68720_1@corp.newsgroups.com...
Quote
> Hell-o again,

> I have another question.
> I want to create something like a scrollable combobox or listbox where
each
> string entry is also accompanied by a small combobox of it's own. This
would
> be sort of like a tCheckListBox component but instead of a check box, I
want
> a small combobox for each entry.

> What I need this is to manage strings, and I want each string to have a
> designation between A and F, and to let the user select the designation
(vis
> the small combo box) (but not change the strings themselves).

> Can anyone help on this?

> All my other questions are answered.

> Thanks,

> Gino :)

> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

Re:more questions, on creating a combobox with list boxes


In article <3ba6872...@corp.newsgroups.com>, "Gino Costa" <gco...@beld.net>
writes:

Quote
>I have another question.
>I want to create something like a scrollable combobox or listbox where each
>string entry is also accompanied by a small combobox of it's own. This would
>be sort of like a tCheckListBox component but instead of a check box, I want
>a small combobox for each entry.

>What I need this is to manage strings, and I want each string to have a
>designation between A and F, and to let the user select the designation (vis
>the small combo box) (but not change the strings themselves).

Put a listbox and a combobox (with style set to csDropDownList). Fill the
combobox with the list of options and the listbox with those selected. Then
code as follows ...

procedure TForm1.ListBox1Click(Sender: TObject);
begin
  {position and drop-down the combobox}
  with ListBox1 do begin
    ComboBox1.SetBounds(Left,
                        Top + ((ItemIndex - TopIndex) * ItemHeight) - 2,
                        Width,
                        ComboBox1.Height);
    {select existing listbox option in combobox}
    ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(Items[ItemIndex]);
    ComboBox1.Text := ComboBox1.Items[ComboBox1.ItemIndex];
    ComboBox1.Visible := true;
    ComboBox1.Perform(CB_SHOWDROPDOWN, 1, 0);
    ComboBox1.SetFocus;
  end;
end;

procedure TForm1.ComboBox1Click(Sender: TObject);
begin
  {transfer the selected item into the listbox}
  with ListBox1 do
    Items[ItemIndex] := ComboBox1.Items[ComboBox1.ItemIndex];
  ComboBox1.Visible := false;
end;

procedure TForm1.ComboBox1KeyUp(Sender: TObject; var Key: Word;
           Shift: TShiftState);
begin
  {close combobox}
  if Key = VK_ESCAPE then
    ComboBox1.Visible := false;
end;

Alan Lloyd
alangll...@aol.com

Other Threads