Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Columns not showing

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

Columns not showing
Link Posted: 26-Oct-2006 01:39
I am using the Flygrid with LeftFixedColumns = 2 and the first column being a hierarchyColumn.  When the form that contains the grid is first shown, the grid will only show the content of the 2 fixed columns while the other columns are blank even though they have values.  Clicking on any part of the grid will make it redraw and show content for all the columns.  Is there some other properties that I need to set to get the grid to show all the contents when first loaded?  Or is there a way to force the grid to redraw when first loaded?

Thanks,

-shl
Link Posted: 26-Oct-2006 03:50
Can you provide me with FlyGrid initialization code (in other words - how FlyGrid is initiliazed, and columns added) or provide sample that describes problem?
One of the ways to solve this problem - embrace FlyGrid initilization code into
FlyGrid.BeginInit/EndInit methods:
[c#]
private void Init(FlyGrid flyGrid)
{
  flyGrid.BeginInit();
  try
  {
    //flyGrid initialization code
    //....
  }
  finally
  {
    flyGrid.EdnInit();
  }
}
Link Posted: 26-Oct-2006 07:30
Here is the code that I am using, thanks.

private void fillDTE()
{
  nestedGrid.BeginInit();
  try
  {
    addGridRows();
    addGridColumns();
    nestedGrid.ItemDragDrop +=
      new NineRays.Windows.Forms.FlyGrid.ItemDragDropHandler(nestedGrid_ItemDragDrop);
  }
  finally
  {
    nestedGrid.EndInit();
    nestedGrid.Refresh();
  }
  nestedGrid.MouseDown += new MouseEventHandler(nestedGrid_MouseDown);      
}


private void addGridColumns()
{
  Columns columns = nestedGrid.Columns;
  columns.Options |= ColumnsOptions.HotTrack;
  columns.HeadersHeight = 50;
  Column col1 = new HierachyColumn(\"Device\", \"Device\");
  Column col2 = new Column(\"Time\", \"Time\");
  Column col3 = new Column(\"Duration (Hrs)\", \"Duration\");
  Column col4 = new DropDownListColumn(\"Cause Of Downtime\", \"Cause Of Downtime\");
  Column col5 = new Column(\"Notes\", \"Notes\");
  Column col6 = new Column(\"Lost Energy(WS)\", \"Lost Energy Wind\");
  Column col7 = new Column(\"Lost Energy(Adj WTG)\", \"Lost Energy Adj\");
  Column col8 = new Column(\"Wind Gen Hrs\", \"wind gen hrs\");
  DropDownListColumn col9 = new DropDownListColumn(\"Downtime Category 1\", \"DTC1\");
  DropDownListColumn col10 = new DropDownListColumn(\"Downtime Category 2\", \"DTC2\");
  DropDownListColumn col11 = new DropDownListColumn(\"Downtime Category 3\", \"DTC3\");
  DropDownListColumn col12 = new DropDownListColumn(\"Downtime Category 4\", \"DTC4\");
  Column col13 = new Column(\"DTP_ID\", \"DTP_ID\");
  Column col14 = new Column(\"DTA1_ID\", \"DTA1_ID\");
  Column col15 = new Column(\"DTA2_ID\", \"DTA2_ID\");
  Column col16 = new Column(\"DTA3_ID\", \"DTA3_ID\");
  Column col17 = new Column(\"DTA4_ID\", \"DTA4_ID\");
  Column col18 = new Column(\"EditStatus\", \"EditStatus\");
  
  col1.ReadOnly = true;
  col2.ReadOnly = true;
  col3.ReadOnly = true;
  col6.ReadOnly = true;
  col7.ReadOnly = true;
  col8.ReadOnly = true;
  col13.Visible = false;
  col14.Visible = false;
  col15.Visible = false;
  col16.Visible = false;
  col17.Visible = false;
  col18.Visible = false;

  col1.FormatFlags &= System.Drawing.StringFormatFlags.DirectionVertical;
  col1.CellBackColor = Color.Lavender;
  col1.FitMode = ColumnFitMode.SmartFit;

  Column[] cols = new Column[] {col1, col2, col3, col4, col5, col6,
        col7, col8, col9, col10, col11, col12,
        col13, col14, col15, col16, col17, col18};
  col9.Changed += new ColumnChangedHandler(DTC1_ColumnChange);
  columns.Items.AddRange(cols);
  columns.LeftFixedColumns = 2;

  for(int n=1;n  {
    columns.Items[n].FormatFlags &=
      System.Drawing.StringFormatFlags.DirectionVertical;
    columns.Items[n].FitMode = ColumnFitMode.SmartFit;
  }
}
Link Posted: 26-Oct-2006 11:09
Seem that problem in adding rows before columns initialization.
1. Try to call addGridColumns() before addGridRows()
2. Can you provide with a part of addGridRows method to analyze how nodes is added to FlyGrid? I've used a small implementation of this procedure for tests, but FlyGrid works correctly.
Link Posted: 26-Oct-2006 13:42
Thanks.  Below is the addGridRows() function.  I changed the order of calls to call addGridColumns() before addGridRows() and it didn't seem to make a difference.  The interesting thing is if I hover the mouse over a  blank column, a 'popup' shows the text that's in the 'blank' column.  The problem seems to go away if I set LeftFixedColumns = 0.  But the LeftFixedColumns feature is something I would really like to have in the grid that I am looking for.  Is there a way to force a redraw of the grid?

Thanks,

-shl

private void addGridRows()
{
  // m_ltDTP is a list of group DTPs.  Each group DTP could
  // be a grouping of 10min DT periods.
  DTP pGroupDTP = null, pSubDTP = null;
  NodeBase node = nestedGrid.Rows.RootNode;      
  DTDef pDTDef = swiSite.DTDefinition;
  Hashtable htAllDTCategories = pDTDef.getAllDTCategories();
  Containers.DTCategory pDTCategory;
  DTA[] DTAs = new DTA[4];
  string[] sDTAText = new string[4];
  nestedGrid.BackColor = SystemColors.Window;
  nestedGrid.Style = GridStyle.XP;
  nestedGrid.Options |= GridOptions.ShowFocusRectangle;
  nestedGrid.Rows.Options |= RowsOptions.Moveable |
    RowsOptions.ShowRowHeaders | RowsOptions.ShowIndicators;
  nestedGrid.Rows.RowSizing = RowSizing.Free;
  //nestedGrid.Columns.Items.Clear();      
  nestedGrid.Rows.Items.Clear();  

  for(int n=0;n<4;n++)
    sDTAText[n] = \"[NA]\";

  for(int n=0;n  {
    pGroupDTP = (DTP) m_ltDTP[n];
    for(int k=0;k    {
      DTAs[k] = (DTA) pGroupDTP.ltDTAs[k];
      if(htAllDTCategories.ContainsKey(DTAs[k].DTCategoryID))
      {
        pDTCategory = (DTCategory) htAllDTCategories[DTAs[k].DTCategoryID];
        sDTAText[k] = pDTCategory.sDTCatgoryName;
      }
    }
    string [][] rootText = new string[][] {
      new string[]{pGroupDTP.devName,
        SWIMiscAux.Functions.realTime(pGroupDTP.st),
        Convert.ToString((pGroupDTP.et - pGroupDTP.st)/3600),
        pGroupDTP.eventText,
        pGroupDTP.note,
        pGroupDTP.lostEnergyWS.ToString(),
        pGroupDTP.lostEnergyWTGAdj.ToString(),
        pGroupDTP.WindGenHrs.ToString(),
        sDTAText[0], sDTAText[1],
        sDTAText[2], sDTAText[2]}};
    AddNestedTo(node, rootText);
    for(int m=0;m    {
      pSubDTP = (DTP) pGroupDTP.ltChildDTPs[m];
      string[][] nodeText = new string[][]
        {
          new string[]{pSubDTP.devName,
                  SWIMiscAux.Functions.realTime(pSubDTP.st),
                  Convert.ToString((pSubDTP.et - pSubDTP.st)/3600),
                  pSubDTP.eventText,
                  pSubDTP.note,
                  pSubDTP.lostEnergyWS.ToString(),
                  pSubDTP.lostEnergyWTGAdj.ToString(),
                  pSubDTP.WindGenHrs.ToString(),
                  DTAs[0].ID.ToString(), DTAs[1].ID.ToString(),
                  DTAs[2].ID.ToString(), DTAs[3].ID.ToString()}};
      AddNestedTo(node, nodeText);
    }
  }
}
Link Posted: 27-Oct-2006 05:10
I added a 2nd level of nested columns to the flygrid and now it seems to redraw all the columns correctly on load.  Not sure why this would make a difference, any thoughts?

Thanks,

-Shl
Link Posted: 27-Oct-2006 08:49
I've noticed that you incorrectly initializing root rows, where total columns (visible and unvisible) count is less when array of cells. This situation cause redimension of cells arrays in the process of displayingand cause incorrect displaying of cells values.
Here is a simple and correct example of node cells initialization, hope this sample help you to correctly initialize cells:
[c#]
private void addGridRows(FlyGrid flyGrid)
{
  for(int i=0; i < 3; i++)
  {
    object[] value = new object[flyGrid.Columns.Items.Count];
    for(int j=0; j < value.Length; j++)
    {
      value[j] = i.ToString()+\"x\" + j.ToString();
    }
    Node node = new Node(value);
    flyGrid.Rows.Items.Add(node);
  }
}