BuilderSpec
Programmer
Hi
Hoping someone can help.
Using C++ builder 6
New Project , add a TButton called Button1 , a DBGrid and associate some data to it. Mine has at least 3 columns of data.
Want the end result to be that in the 3rd column I want a button to display.
I have got this so far :
void __fastcall TForm1:BGrid1DrawColumnCell(TObject *Sender,
const TRect &Rect, int DataCol, TColumn *Column,
TGridDrawState State)
{
if ( Button1->Parent != DBGrid1 )
Button1->Parent = DBGrid1;
if ( Column->Index == 2 )
{
if ( State.Contains(gdFocused) )
{
if ( Button1->Left != (Rect.Right - Button1->Width ) )
Button1->Left = Rect.Right - Button1->Width ;
if ( Button1->Top != Rect.Top )
Button1->Top = Rect.Top;
if ( Button1->Height != ( Rect.Bottom - Rect.Top ) )
Button1->Height = Rect.Bottom - Rect.Top ;
Button1->Visible = true;
}
}
}
Only issue is that it only shows the button if I am on that record and would like it to show the button on all records. The above only shows the button per line if i click into column 3. Would like the button to show regardless if possible for all rows. But at the least to show button when i enter the record regardless of column.
Any ideas please ?
Graham
Hope this helps!
Regards
BuilderSpec
Hoping someone can help.
Using C++ builder 6
New Project , add a TButton called Button1 , a DBGrid and associate some data to it. Mine has at least 3 columns of data.
Want the end result to be that in the 3rd column I want a button to display.
I have got this so far :
void __fastcall TForm1:BGrid1DrawColumnCell(TObject *Sender,
const TRect &Rect, int DataCol, TColumn *Column,
TGridDrawState State)
{
if ( Button1->Parent != DBGrid1 )
Button1->Parent = DBGrid1;
if ( Column->Index == 2 )
{
if ( State.Contains(gdFocused) )
{
if ( Button1->Left != (Rect.Right - Button1->Width ) )
Button1->Left = Rect.Right - Button1->Width ;
if ( Button1->Top != Rect.Top )
Button1->Top = Rect.Top;
if ( Button1->Height != ( Rect.Bottom - Rect.Top ) )
Button1->Height = Rect.Bottom - Rect.Top ;
Button1->Visible = true;
}
}
}
Only issue is that it only shows the button if I am on that record and would like it to show the button on all records. The above only shows the button per line if i click into column 3. Would like the button to show regardless if possible for all rows. But at the least to show button when i enter the record regardless of column.
Any ideas please ?
Graham
Hope this helps!
Regards
BuilderSpec