Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2005.10.16;
Скачать: [xml.tar.bz2];

Вниз

ComboBox. Как добавить колонки в выпадающий список?   Найти похожие ветки 

 
Voffka   (2005-09-28 11:10) [0]

Все перерыл уже.  Устал ;(. Что-то я никак не пойму возможно ли это вообще. Кажется такая мелочь должна присутствовать в TComboBox, а найти никак не могу. Подскажите где искать, или как подменять выпадающий список ListBox-ом. Заранее спасибо.


 
CHES ©   (2005-09-28 11:22) [1]

ComboBox1.Items.Add("Your string")


 
Voffka   (2005-09-28 11:29) [2]


> CHES ©   (28.09.05 11:22) [1]
> ComboBox1.Items.Add("Your string")

и как это мне поможет создать в выпадающем списке вторую колонку?


 
dmitry501 ©   (2005-09-28 11:36) [3]

А почитать разные факи пробовали? Например вот-

procedure TForm1.ComboBox1DrawItem(Control: TWinControl;  
 Index: Integer; Rect: TRect; State: TOwnerDrawState);  
var  
 strVal, strAll: string;  
 pos1, pos2: Integer;  
 rc: TRect;  
 arrWidth: array [0..3] of Integer;  
begin  
 Combobox1.Canvas.Brush.Style := bsSolid;  
 Combobox1.Canvas.FillRect(Rect);  
 // the columns must be separated by ";"  
 strAll := Combobox1.Items[Index];  

 arrWidth[0] := 0;  
 arrWidth[1] := 100;  // Width of column 1  
 arrWidth[2] := 200;  // Width of column 2  
 arrWidth[3] := 300;  // Width of colimn 3  

 // Drawingrange for first column  
 rc.Left   := Rect.Left + arrWidth[0] + 2;  
 rc.Right  := Rect.Left + arrWidth[1] - 2;  
 rc.Top    := Rect.Top;  
 rc.Bottom := Rect.Bottom;  

 // Get text for first column  
 pos1   := Pos(";", strAll);  
 strVal := Copy(strAll, 1, pos1 - 1);  
 // Draw Text  
 Combobox1.Canvas.TextRect(rc, rc.Left, rc.Top, strVal);  
 // Draw separating line betwenn columns  
 Combobox1.Canvas.MoveTo(rc.Right, rc.Top);  
 Combobox1.Canvas.LineTo(rc.Right, rc.Bottom);  

 // Drawingrange for second column  
 rc.Left  := Rect.Left + arrWidth[1] + 2;  
 rc.Right := Rect.Left + arrWidth[2] - 2;  

 // Text fur zweite Spalte ausfiltern  
 // Get text for second column  
 strAll := Copy(strAll, pos1 + 1, Length(strAll) - pos1);  
 pos1   := Pos(";", strAll);  
 strVal := Copy(strAll, 1, pos1 - 1);  

 // Text ausgeben  
 // Draw Text  
 Combobox1.Canvas.TextRect(rc, rc.Left, rc.Top, strVal);  
 // Trennlinie zwischen Spalten zeichnen  
 // Draw separating line betwenn columns  
 Combobox1.Canvas.MoveTo(rc.Right, rc.Top);  
 Combobox1.Canvas.LineTo(rc.Right, rc.Bottom);  

 // Drawingrange for third column  
 rc.Left  := Rect.Left + arrWidth[2] + 2;  
 rc.Right := Rect.Left + arrWidth[3] - 2;  

 // Get text for third column  
 strAll := Copy(strAll, pos1 + 1, Length(strAll) - pos1);  
 pos1   := Pos(";", strAll);  
 strVal := Copy(strAll, 1, pos1 - 1);  

 // Draw Text  
 Combobox1.Canvas.TextRect(rc, rc.Left, rc.Top, strVal);  
 // Draw separating line betwenn columns  
 Combobox1.Canvas.MoveTo(rc.Right, rc.Top);  
 Combobox1.Canvas.LineTo(rc.Right, rc.Bottom);  
 strAll := Copy(strAll, pos1 + 1, Length(strAll) - pos1);  
end;  

// Example/ Beispiel:  

procedure TForm1.Button1Click(Sender: TObject);  
begin  
 with Combobox1.Items do  
 begin  
   Add("first;second;third;");  
   Add("column1;column2;column3;");  
 end;  
end;  

procedure TForm1.FormCreate(Sender: TObject);  
begin  
 //Oder im Objekt Inspektor einstellen  
 //Or set this Property in the Object Inspector  
 Combobox1.Style := csOwnerDrawFixed;  
end;


   
Взято с http://delphiworld.narod.ru


 
Voffka   (2005-09-28 11:46) [4]

спасибо, но рисовать разделители и я могу, но это не разделение на колонки как в ListBox, т.е. каждый элемент колонки это отдельный item


 
Amoeba ©   (2005-09-28 13:16) [5]

В таком случае придется писать с нуля собственный компонент.


 
Voffka   (2005-09-28 13:27) [6]


> Amoeba ©   (28.09.05 13:16) [5]
> В таком случае придется писать с нуля собственный компонент.
>

мда, это мясо ;(


 
Amoeba ©   (2005-09-28 14:19) [7]

Посмотри на http://www.torry.net/pages.php?id=134 компонент TColumnListBox v.1.2 (если без исходников, то он бесплатный)



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

Форум: "Основная";
Текущий архив: 2005.10.16;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.12 c
3-1125657938
Alex Kryuchkov
2005-09-02 14:45
2005.10.16
Транзакции в DBXpress


1-1127307607
DelphiLexx
2005-09-21 17:00
2005.10.16
Избежать мерцания при перемещении


6-1119571665
z3oN
2005-06-24 04:07
2005.10.16
Winsock получение ответа от сервера ?


9-1118048201
WandR
2005-06-06 12:56
2005.10.16
Ландшафт


2-1126403102
Иванька
2005-09-11 05:45
2005.10.16
Таблица и Excel





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский