Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Общие вопросы > сделать item of combobox enabled


Автор: saltonik 9.3.2011, 20:38
Здравствуйте форумчане! у меня вопрос - можно ли item combobox-a сделать enabled?

Например вот итемы комбобокса:
1
   - 1.1
   - 1.2
   - 1.3
2
  - 2.1
  - 2.2
  - 2.3

Можно ли сделать так чтобы "1" и "2"  были как бы enabled?

p.s. Пробывала так:

Код

case ComboBox1.ItemIndex of
0,4:ComboBox1.ItemIndex:=-1;
end;


не получается(( помогите плииз

Автор: Akella 10.3.2011, 10:24
Цитата(saltonik @  9.3.2011,  20:38 Найти цитируемый пост)
можно ли item combobox-a сделать enabled?

а что, они disabled?

Автор: pseud 10.3.2011, 16:33
Цитата(saltonik @  9.3.2011,  20:38 Найти цитируемый пост)
Можно ли сделать так чтобы "1" и "2"  были как бы enabled?

Наверно имел ввиду "верхние уровни невыбираемые"?
Ну что-то типа делай раз:
- бросаем на форму Combobox1;
- Combobox1.Items = 
Цитата

1 qweqweqwe
  1.2 sdfsdfsdf
  1.3 dfsdfsdf
2 cvbcvbcvb
  2.1 sdfsdfsdf

- Combobox1.Style = csOwnerDrawFixed;
- Combobox1.OnDrawItem = 
Код

procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  TControlCanvas(ComboBox1.Canvas).UpdateTextFlags;
  if Index >= 0 then
  begin
    if Index in [0,3] then
    begin
      ComboBox1.Canvas.Font.Color := clGray;
      ComboBox1.Canvas.Brush.Color := ComboBox1.Color;
    end;
    ComboBox1.Canvas.FillRect(Rect);
    ComboBox1.Canvas.TextOut(Rect.Left + 2, Rect.Top, ComboBox1.Items[Index]);
  end;
end;

- Combobox1.OnSelect =
Код

procedure TForm1.ComboBox1Select(Sender: TObject);
begin
  if ComboBox1.ItemIndex in [0,3] then
    ComboBox1.ItemIndex := ComboBox1.ItemIndex + 1;
end;

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)