bv7
Зарегистрирован: 13.10.2008 Сообщения: 6
|
Добавлено: Вт Июн 02 2009 13:22 Заголовок сообщения: Delphi DGBrid помещение компонента в ячейку сетки данных |
|
|
При помещении компонента DBComboBoxв ячейку DBGrid'a не производится выборка значений. В чем причина?
Код: |
begin
FEditor := TDBComboBox.Create(Self);
FEditor.Parent := Self;
FEditor.Visible := false;
FEditor.Style := csDropdownList;
FEditor.DataSource := DBGrid1.DataSource;
FEditor.DataField := 'CEH';
for I:=0 to Pred(DBGrid1.Columns.Count) do
if DBGrid1.Columns[I].Field.FieldName = FEditor.DataField then
begin
FEditor.Items.Assign(DBGrid1.Columns[I].PickList);
Break;
end;
end;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (gdFocused in State) then
if (Column.Field.FieldName = FEditor.DataField) then
begin
FEditor.Left := Rect.Left + DBGrid1.Left;
FEditor.Top := Rect.Top + DBGrid1.top;
FEditor.Width := Rect.Right - Rect.Left + 2;
FEditor.Visible := True;
end;
end;
procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
if DBGrid1.SelectedField.FieldName = FEditor.DataField then
FEditor.Visible := false;
end;
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if (Key <> chr(9)) then
if (DBGrid1.SelectedField.FieldName = FEditor.DataField) then begin
FEditor.SetFocus;
SendMessage(FEditor.Handle, WM_CHAR, word(Key), 0);
end;
end;
|
|
|