![]() |
|
#1
|
|||
|
|||
|
i intend to show a listbox exactly over (in front of) a specific column of a dbgrid, when i click the dbgrid's title. How can i get the coordinates of the column? like Left and Top or x,y ?
thank you for the help mario |
|
#2
|
|||
|
|||
|
Try this:
[DELPHI]procedure TForm1.DBGrid1TitleClick(Column: TColumn); var i, iLeft : Integer; begin DBGrid1.SelectedField := Column.Field; iLeft := 0; for i:=0 to Column.Index-1 do iLeft := iLeft + DBGrid1.Columns[i].Width; ListBox1.Top := DBGrid1.Top; ListBox1.Left := iLeft; ListBox1.Height := DBGrid1.Height; ListBox1.Width := Column.Width+17; end;[/DELPHI] Regards, Abdulaziz Jasser |
|
#3
|
|||
|
|||
|
A better one:
[DELPHI]procedure TForm1.DBGrid1TitleClick(Column: TColumn); var i, iLeft : Integer; begin DBGrid1.SelectedField := Column.Field; iLeft := 6; for i:=0 to Column.Index-1 do iLeft := iLeft + DBGrid1.Columns[i].Width; ListBox1.Top := DBGrid1.Top; ListBox1.Left := iLeft; ListBox1.Height := DBGrid1.Height; ListBox1.Width := Column.Width; if dgIndicator in DBGrid1.Options then ListBox1.Width := ListBox1.Width+17; end;[/DELPHI] Regards, Abdulaziz Jasser |
|
#4
|
|||
|
|||
|
A much better one:
[DELPHI]procedure TForm1.DBGrid1TitleClick(Column: TColumn); var Rect : TRect; begin DBGrid1.SelectedField := Column.Field; Rect := TStringGrid(DBGrid1).CellRect(Column.Index,1); ListBox1.Top := Rect.Top; ListBox1.Left := Rect.Left; ListBox1.Height := DBGrid1.Height-((Rect.Bottom-Rect.Top)*2)-1; ListBox1.Width := Rect.Right-Rect.Left+2; end;[/DELPHI] Regards, Abdulaziz Jasser |
![]() |
| Thread Tools | |
| Display Modes | |
|
|