Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Node Indexes...

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

Node Indexes...
Link Posted: 12-Jan-2006 09:42
I think I found a bug...

I have situations when I must hide/show columns at random depending on conditions in my flygrid.  If I have four columns and I hide the third one the index for my 4th column changes to 2 rather than remaining 3 as it should.  It seems to me that whether a column is hidden or visible if it is in the collection it's index should remain unchanging so that if someone wanted to use constants that they spread of several classes (i.e.  inherited nodes, etc) they could do so.

I'm overriding the OnNodeClick event to get my index, btw.

Any assistance is appreciated.  Right now I've resorted to using inherited classes so I can do type-checking rather than relying on the index because it is incorrect.

Corey
Link Posted: 16-Jan-2006 08:50
This problem already solved in the last FlyGrid.Net update.
Link Posted: 16-Jan-2006 13:05
I am using version 1.2.12 and I'm afraid the previous repair did not work.  

I have nine columns in my grid with the following captions:

Name | Crop | Area | Bdy. Area | Use Bdy. Area | Rep. Area | Use Rep. Area | Fsa Area | Use Fsa Area

In my code based on a boolean I execute the following statement

this.colArea.Visible = false;

That statement hides the third column.

Following that statement I rebuild the app and go to the UI to run a simple test.  I click on the 7th column (index of 6) and inside the OnNodeClick method col is set to 5 rather than 6 as it should be.

Thanks ahead,

Corey
Link Posted: 17-Jan-2006 02:41
When columns can be moved or hidden use columns mapping features of FlyGrid.
[list]
  • If you want to find column at certain visible cell index, use Columns.VisibleColumns
  • [columnIndex].[/*:m]
  • If you want to find index of field value in the array of values by column value or it's fieldName, use Columns.FieldMapIndexOf(column.FieldName) or Columns.FieldMapIndexOf(column) methods.
    Index of field value in the array of node values doesn't restructured when column moved or comes unvisible, internal columns map is restructured to point real index of field value associated with some FieldName.
    It will more better if you'll use direct way:
    private SetValue(NodeBase node, Column col, object value)
    {
       node
  • [col] = value;
    }

    private SetValue(NodeBase node, string fieldName, object value)
    {
       node[fieldName] = value;
    }
    [/*:m]
  • If you want to get value from some visible cell, you can combine these methods:
    private SetValue(FlyGrid flyGrid, NodeBase node, int cellIndex, object value)
    {
       Column col = flyGrid.Columns.VisibleColumns
  • [cellIndex];
       node[col] = value;
    }
    [/*:m][/list:u]