Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Manually Finding & Removing Items (no databinding)

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

Manually Finding & Removing Items (no databinding)
Link Posted: 16-Jan-2007 00:48
How is it possible to find and remove items?

flyGrid1->Rows->Items->Add(newNode); and newNode->Items->Add(newNode2); return an integer of its position rather than a pointer to it, so how can you find it again?
Link Posted: 17-Jan-2007 00:08
You can find node by it index -
[c#]
int index = node.Index;
if (index != -1)
{
  NodeBase parentNode = node.Parent;
  parentNode.Items.RemoveAt(index);
}
but more convenient way:
[c#]
if (node.Parent != null)
{
  node.Parent.Items.Remove(node);
}
Link Posted: 18-Jan-2007 03:28
Since it is an index, won't it change if the data is sorted or if an item is inserted?
Link Posted: 18-Jan-2007 05:11
This index is dynamic (can be changed after sorting, removal or insertion another nodes), when you require Node.Index you receive current index in the parent nodes collection -
it is the same as following code
[c#]
public int GetNodeIndex(NodeBase node)
{
  NodeBase parentNode = node.Parent;
  return parentNode != null ? parentNode.Items.IndexOf(node) : -1;
}