Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Is it possible to set read only on specific cells

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

Is it possible to set read only on specific cells
Link Posted: 06-Dec-2005 21:33
Hello!

I need to be able to set read only on a arbitrary cells is that possible.
If yes have you same piece of sample to show that.

//Tony
Link Posted: 07-Dec-2005 01:49
[C#]
    internal class NodeWithReadOnly : Node
    {
      private bool readOnly = false;
      public bool ReadOnly
      {
        get
        {
          return readOnly;
        }
        set
        {
          readOnly = value;
        }
      }
    }


Usage of this class:
[C#]
private void FillGrid(FlyGrid flyGrid)
{
  //add nodes and mark odd nodes as ReadOnly
  for(int i=0; i < 10; i++)
  {
   NodeWithReadOnly newNode = new NodeWithReadOnly("Node" + i.ToString());
    newNode.ReadOnly = i % 2 > 0;odd nodes is readonly
    flyGrid.Rows.Items.Add(newNode);
  }
  //connect to IsReadOnly event
  flyGrid.IsReadOnly += new NodeBoolHandler(flyGrid_IsReadOnly);
}

private bool flyGrid_IsReadOnly(object sender, NodeBase node)
{
  NodeWithReadOnly nro = node as NodeWithReadOnly;
  return nro != null ? nro.ReadOnly : false;
}
Link Posted: 07-Dec-2005 17:22
BTW, in the prepared for release new version of FlyGrid, support of ReadOnly will embedded.
You can use NodeBase.ReadOnly property to set node into ReadOnly state, this state will supported FlyGrid to prevent node with ReadOnly = true from editing. IsReadOnly event can be used to dynamically enable/disable node editing and will called even node.ReadOnly == true.