Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  3 669

•  TDictionary Custom Sort  5 800

•  Fast Watermark Sources  5 603

•  3D Designer  8 218

•  Sik Screen Capture  5 913

•  Patch Maker  6 388

•  Айболит (remote control)  6 378

•  ListBox Drag & Drop  5 237

•  Доска для игры Реверси  94 551

•  Графические эффекты  6 570

•  Рисование по маске  5 644

•  Перетаскивание изображений  4 759

•  Canvas Drawing  5 135

•  Рисование Луны  4 863

•  Поворот изображения  4 411

•  Рисование стержней  3 116

•  Paint on Shape  2 360

•  Генератор кроссвордов  3 228

•  Головоломка Paletto  2 551

•  Теорема Монжа об окружностях  3 328

•  Пазл Numbrix  2 200

•  Заборы и коммивояжеры  2 849

•  Игра HIP  1 820

•  Игра Go (Го)  1 740

•  Симулятор лифта  2 072

•  Программа укладки плитки  1 798

•  Генератор лабиринта  2 240

•  Проверка числового ввода  1 925

•  HEX View  2 225

•  Физический маятник  1 911

 
скрыть

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Несколько колонок в TComboBox




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); 
  // Die einzelnen Spalten mussen durch ';' getrennt sein 
  // 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 

  // Zeichenbereich fur erste Spalte 
  // 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; 

  // Text fur erste Spalte ausfiltern 
  // Get text for first column 
  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); 

  // Zeichenbereich fur zweite Spalte 
  // 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); 

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

  // Text fur dritte Spalte ausfiltern 
  // Get text for third 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); 
  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;








Copyright © 2004-2025 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте