Home - Forums-.NET - FlyGrid.Net (Windows Forms) - ButtonColumn

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

ButtonColumn
Link Posted: 09-Jan-2006 03:09
Hi,
Can i have a button column which has a diffrent buttoncaption in evry row?

if not, how can i make this happend?

thanks, Guy
Link Posted: 09-Jan-2006 13:49
It doesn't seem like the ButtonCaption is the dci.Text property, which would be the easiest way.  

Probably the boys at 9rays have a better way, but you could start with something like:


using System;
using System.Drawing;

using NineRays.Windows.Forms.Grids;
using NineRays.Windows.Forms.Data;
using NineRays.Windows.Drawing;

namespace flygrid
{
  public class CustomButtonColumn : ButtonColumn
  {
    public CustomButtonColumn(string name, string field) : base(name, field)
    {
      this.ButtonCaption = "";
    }

    public override void PaintCellValue(CellDrawInfo dci)
    {
      base.PaintCellValue (dci);

      //Do whatever you need to do to determine your button caption
      System.Data.DataRowView data = dci.node.Value as System.Data.DataRowView;
      if(data!=null)
      {
        string text = data["Caption"].ToString();
        // Custom paint of Caption
        dci.g.DrawString(text, dci.Font, new SolidBrush(ForeColor), dci.cellRect);
      }
    }
  }
}
Link Posted: 16-Jan-2006 01:59
ninerays, can you please answer this question.
Link Posted: 16-Jan-2006 02:31
If you see the Xtras\Task manager sample, you can find the easiest way to modify button caption -
[C#]
private void ModifyNodeCaption(Column col, NodeBase node, string caption)
{
  node[col] = caption;
}


or

[C#]
private void ModifyNodeCaption(string fieldName, NodeBase node, string caption)
{
  node[fieldName] = caption;
}
Link Posted: 16-Jan-2006 21:43
i looked in the sample, and i cant find those functions...
please help me.

thanks,
Guy
Link Posted: 17-Jan-2006 02:25
Sorry for incorrect answer, yes in the current version you can't use different button captions in the ButtonColumn.
In the nearest update of FlyGrid.Net, ButtonColumn will supports node's cell value as button caption, just set ButtonColumn.CellValueAsButtonCaption to true (by default this value will false).
Update is planned to release to the end of this week.