Home - Forums-.NET - FlyGrid.Net (Windows Forms) - how can I hide a button

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

how can I hide a button
Link Posted: 19-Sep-2005 02:35
Hi,
I have a button column with an image on it. I want it to be visible for all rows but the last one (new row). How can I disable the column and make the button invisible for this last row only ?

Thanks
Link Posted: 20-Sep-2005 00:25
You can create your own ButtonColumn inheritor and override ButtonColumn.PaintCellValue to skip button painting:
[C#]
public override void PaintCellValue(CellDrawInfo dci)
{
  if (!dci.node is IAddNewNode)
  {
     base.PaintCellValue(dci);
   }
}


or you can simply disable button in the cell of this row:
[C#]
private void ConnectToButtonColumn(FlyGrid flygrid, int indexOfButtonColumn)
{
  ButtonColumn bc = flyGrid.Columns.Items[indexOfButtonColumn] as ButtonColumn;
  //connect to ButtonEnabled handler
  bc.ButtonEnabled += new ButtonEnabledHandler(OnButtonEnabled);
}

//ButtonEnabled handler
private bool OnButtonEnabled(object sender, NodeBase node)
{
   return !(node is IAddNewNode);
}
Link Posted: 20-Sep-2005 01:24
Thanks for the reply.
This is not exactely what I want. I want to make it invisible on New Row. The code you gave me is for enabling-disabling the button. That works but it would be better if the button becomes invisible instead.
Can you help further ?

Thx
Link Posted: 20-Sep-2005 01:40
But the first code is actually hides button.
Link Posted: 20-Sep-2005 01:42
Thanks it works just fine by overriding the buttoncolumn !!

Solved.
Link Posted: 20-Sep-2005 01:56
To the next version we'll insert ButtonVisible event to handle button visiblity via events.
Link Posted: 20-Sep-2005 02:09
OK