Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.009 c
14-50432
Soft
2003-05-28 11:42
2003.06.16
В чем смысл смысла?


14-50445
jack128
2003-05-28 22:04
2003.06.16
IDE


3-50251
Sharik_212
2003-05-26 22:15
2003.06.16
Помогите по DbGrid


8-50403
Anatoliy D
2003-02-28 08:06
2003.06.16
звуковой редактор


1-50297
killer
2003-06-04 17:04
2003.06.16
Как в программе выделить и скопировать текст из Label-а?




   Наверх