Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.06.16;
Скачать: CL | DM;

Вниз

Двустрочный итем в ComboBox   Найти похожие ветки 

 
McSimm2   (2003-06-03 09:16) [0]

Как нибудь можно осуществить сабж? Если длина строки > 30 символов делать двойной,тройной, ... если - нет: одинарный.


 
NewN ©   (2003-06-03 10:13) [1]

Всё просто. Свойство Style должно быть lbOwnerDrawVariable;

procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
var
i: Integer;
begin
Height:= ((TListBox(Control).Canvas.TextWidth(TListBox(Control).Items[Index]) div TListBox(Control).ClientWidth) + 1) * Height;
end;

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
TListBox(Control).Canvas.FillRect(Rect);
DrawText(TListBox(Control).Canvas.Handle, PChar(TListBox(Control).Items[Index]),
Length(TListBox(Control).Items[Index]), Rect, DT_LEFT or DT_WORDBREAK);
end;


 
JohnJ ©   (2003-06-03 10:19) [2]

Чё-то сложно... А я бы разделял "в ручную"...


 
McSimm2   (2003-06-03 10:35) [3]

To NewN:

апочему TlistBox ?


 
NewN ©   (2003-06-03 11:29) [4]

To NewN:

апочему TlistBox ?

>>Ошибся, невнимательно читал. Надо TCombobox


 
McSimm2   (2003-06-03 11:37) [5]

Команду
TComboBox(Control).Canvas.TextWidth
не воспринимает ...


 
MetalFan ©   (2003-06-03 11:44) [6]

а как это "провернуть" в DBLookUpComboBox ?
есть идеи?


 
McSimm2   (2003-06-03 11:52) [7]

To MetallFan:
Я в результате вот так сделал:

procedure TFrm_main.CmbBox_TDomMeasureItem(Control: TWinControl;
Index: Integer; var Height: Integer);
var
h,h2,h3: Integer;
begin
if index <> -1 then
begin
h := length(TComboBox(Control).Items.Strings[Index])*TComboBox(Control).Font.Size;
h2 := TComboBox(Control).ClientWidth;
h3 := TComboBox(Control).ItemHeight;
Height := (h div h2+1) * h3;
end;
end;


 
MetalFan ©   (2003-06-03 13:04) [8]

а для DB? нету там такого события...



Страницы: 1 вся ветка

Текущий архив: 2003.06.16;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.017 c
3-50251
Sharik_212
2003-05-26 22:15
2003.06.16
Помогите по DbGrid


7-50531
GrafDeKaliostro
2003-04-11 11:16
2003.06.16
Предотвратить удаление файлов


1-50391
TButton
2003-05-31 11:33
2003.06.16
DLL


8-50405
beginer85
2003-02-04 22:55
2003.06.16
как определить битрейт и длину МП3 файла?


1-50346
vitall
2003-06-01 05:17
2003.06.16
OpenPictureDialog ? :)