FlexGrid not showing all rows

Posted by: brian.copeland on 9 August 2022, 11:54 am EST

  • Posted 9 August 2022, 11:54 am EST

    This is a strange issue with Winforms Version 6 with the FlexGrid.

    I have created a FlexGrid on my form. And am cycling through a List<> to populate it.

    When I step through the code I see that all items in the list are added as rows to the grid.

    If I do a fgd.Rows.Count it shows the proper number of rows.

    If I do a fgd.Rows[xxxx].IsVisible on any of those rows it says they are visible.

    However, they are not. In fact the grid only shows anywhere from 60 to 150 rows depending on the list (the same code runs that populates the grid) and that is where the vertical scrollbar ends. Each list will show the same amount of rows. i.e. List will show 147 rows, List will show 64 rows, etc. That is consistent (despite having over 200 items, and the grid Rows.Count says it is over 200).

    Not sure what other information I can provide. Not sure screen shots will help as it will just show the grid with the scrollbar.

  • Posted 10 August 2022, 2:44 am EST

    Hi,

    We tested the issue by creating a small sample in which we populated the C1FlexGrid by cycling through a List<>, but we could not see the issue at our end. Kindly refer to the attached sample showing the same.

    Could you please provide a small sample or update the attached sample to replicate the issue, so we can investigate further and assist you in the best way possible?

    Also, please let us know if you are setting any specific properties in the C1FlexGrid, or using any specific type of Data that can cause this issue. We tested the issue with version 6.0.20222.566 of the C1FlexGrid. Please let us know the version you are using so we can see if the issue is version specific or not.

    FlexGridSample.zip

    Thanks, and Kind Regards,

    Kartik

  • Posted 10 August 2022, 11:11 am EST

    Hi Kartik, thank you for getting back to me.

    Here is the code that setups up the grid:

    fgdNav.Clear();
    
                fgdNav.Font = new Font("Segoe UI", 9);
    
                CellStyle cs = fgdNav.Styles.Add("selected");
                cs.Font = new Font("Arial", 8, FontStyle.Bold);
                cs.BackgroundImage = Properties.Resources.selected_background;
                cs.BackgroundImageLayout = ImageAlignEnum.TileStretch;
                cs.ForeColor = Color.White;
    
                cs = fgdNav.Styles.Add("wantListLowPriority");
                cs.ForeColor = Color.LightBlue;
                cs.TextAlign = TextAlignEnum.LeftCenter;
    
                cs = fgdNav.Styles.Add("wantListNormalPriority");
                cs.ForeColor = Color.LightGreen;
                cs.TextAlign = TextAlignEnum.LeftCenter;
    
                cs = fgdNav.Styles.Add("wantListMediumPriority");
                cs.ForeColor = Color.Violet;
                cs.TextAlign = TextAlignEnum.LeftCenter;
    
                cs = fgdNav.Styles.Add("wantListHighPriority");
                cs.ForeColor = Color.Orange;
                cs.TextAlign = TextAlignEnum.LeftCenter;
    
                cs = fgdNav.Styles.Add("wantListUrgentPriority");
                cs.ForeColor = Color.Red;
                cs.TextAlign = TextAlignEnum.LeftCenter;
    
                cs = fgdNav.Styles.Add("wantListOtherDenomination");
                cs.BackColor = Color.LightGray;
    
                cs = fgdNav.Styles.Add("unselected");
                cs.BackColor = Color.White;
                cs.Font = new Font("Arial", 8, FontStyle.Regular);
    
                cs = fgdNav.Styles.Add("denomination");
                cs.BackgroundImage = Properties.Resources.denomination_background;
                cs.BackgroundImageLayout = ImageAlignEnum.LeftCenter;
                cs.Font = new Font("Arial", 10, FontStyle.Bold);
                cs.ForeColor = Color.White;
    
                cs = fgdNav.Styles.Add("gainpercent");
                cs.ForeColor = Color.Blue;
                cs.Font = new Font("Arial", 8, FontStyle.Bold);
    
                cs = fgdNav.Styles.Add("losepercent");
                cs.ForeColor = Color.Red;
                cs.Font = new Font("Arial", 8, FontStyle.Regular);
    
                cs = fgdNav.Styles.Add("percent");
                cs.ForeColor = Color.Black;
                cs.Font = new Font("Arial", 8, FontStyle.Regular);
    
                cs = fgdNav.Styles.Add("centered");
                cs.TextAlign = TextAlignEnum.CenterCenter;
    
                cs = fgdNav.Styles.Add("serialnumber");
                cs.TextAlign = TextAlignEnum.LeftCenter;
    
                fgdNav.AllowAddNew = false;
                fgdNav.AllowDelete = false;
                fgdNav.AllowDragging = AllowDraggingEnum.None;
                fgdNav.AllowEditing = false;
                fgdNav.AllowFreezing = AllowFreezingEnum.None;
                fgdNav.AllowMerging = AllowMergingEnum.Free;
    
                fgdNav.AllowResizing = AllowResizingEnum.None;
                fgdNav.AllowSorting = AllowSortingEnum.None;
                fgdNav.BorderStyle = C1.Win.FlexGrid.Util.BaseControls.BorderStyleEnum.None;
                fgdNav.ExtendLastCol = true;
                fgdNav.FocusRect = FocusRectEnum.None;
                fgdNav.SelectionMode = SelectionModeEnum.Row;
    
                fgdNav.Styles["Normal"].Border.Style = BorderStyleEnum.None;
                fgdNav.Styles["EmptyArea"].Border.Style = BorderStyleEnum.None;
    
                fgdNav.HighLight = HighLightEnum.Never;
    
                fgdNav.DrawMode = DrawModeEnum.OwnerDraw;
    fgdNav.Cols.Count = 10;
                            fgdNav.Cols.Fixed = 0;
                            fgdNav.Rows.Count = 1;
                            fgdNav.Rows.Fixed = 1;
    
                            fgdNav.Cols[0].Width = 50;
                            fgdNav.Cols[1].Width = 50;
                            fgdNav.Cols[2].Width = 50;
                            fgdNav.Cols[3].Width = 50;
                            fgdNav.Cols[4].Width = 60;
                            fgdNav.Cols[5].Width = 50;
                            fgdNav.Cols[6].Width = 100;
                            fgdNav.Cols[7].Width = 60;
                            fgdNav.Cols[8].Width = 400;
    
                            fgdNav.SetData(0, 1, "Own");
                            fgdNav.SetData(0, 2, "Want");
                            fgdNav.SetData(0, 3, "Need");
                            fgdNav.SetData(0, 4, "Upgrade");
                            fgdNav.SetData(0, 5, "Key");
                            fgdNav.SetData(0, 6, "Year");
                            fgdNav.SetData(0, 7, "MM");
                            fgdNav.SetData(0, 8, "Variety/Description");
                            fgdNav.SetData(0, 9, "Denomination");
    fgdNav.ResumeLayout();
                fgdNav.BringToFront();
    
    

    Next is the code to populate the list items into the grid:

    
    fgdNav.SuspendLayout();
    foreach (CoinCatalogGridModel coin in coins.ToList())
                        {
                            string strPotentialDenomination = "";
    
                            if (currentView == eView.Catalog_Coin || currentView == eView.Collection_Coin)
                            {
                                strPotentialDenomination = coin.Denomination;
                            }
                            else if (currentView == eView.Catalog_CollectorCoin)
                            {
                                strPotentialDenomination = coin.NumismaticSeriesName;
                            }
    
                            if (strPotentialDenomination == "")
                                strPotentialDenomination = "No Series";
    
                            // Add denomination row if required
                            //if (currentDenomination != strPotentialDenomination)
                            //{
                            //    currentDenomination = strPotentialDenomination;
    
                            //    fgdNav.Rows.Count++;
    
                            //    intCurrentRow = fgdNav.Rows.Count - 1;
    
                            //    fgdNav.Rows[intCurrentRow].Height = 20;
    
                            //    CellRange cel = new CellRange
                            //    {
                            //        r1 = intCurrentRow,
                            //        r2 = intCurrentRow,
                            //        c1 = 0,
                            //        c2 = fgdNav.Cols.Count - 1
                            //    };
    
                            //    fgdNav.SetData(cel, currentDenomination);
                            //    fgdNav.Cols[0].AllowMerging = fgdNav.Cols[fgdNav.Cols.Count - 1].AllowMerging = true;
                            //    fgdNav.Rows[intCurrentRow].AllowMerging = true;
    
                            //    fgdNav.SetCellImage(intCurrentRow, 0, iml.Images["Denomination"]);
    
                            //    fgdNav.Cols[0].ImageAlign = ImageAlignEnum.LeftCenter;
                            //    fgdNav.Rows[intCurrentRow].UserData = "Denomination|" + currentDenomination;
                            //    fgdNav.SetUserData(intCurrentRow, 0, coin.DenominationID.ToString());
                            //    fgdNav.Rows[intCurrentRow].IsNode = true;
    
    
                            //}
    
                            fgdNav.Rows.Count++;
                            intCurrentRow = fgdNav.Rows.Count - 1;
    
                            fgdNav.SetUserData(intCurrentRow, 0, coin.ID.ToString());
                            fgdNav.SetData(intCurrentRow, 6, coin.Year.ToString());
                            fgdNav.SetData(intCurrentRow, 7, coin.MintMark);
                            fgdNav.SetData(intCurrentRow, 8, intCurrentRow.ToString() + " " +  coin.Variety);
    
                            
                            fgdNav.Rows[intCurrentRow].UserData = coin.ID.ToString();
    
                            fgdNav.Rows[intCurrentRow].IsNode = true;
    
                            fgdNav.Rows[intCurrentRow].Height = 20;
                            fgdNav.Rows[intCurrentRow].Visible = true;
    	}
    fgdNav.ResumeLayout();
    
    

    The section that says ‘add denomination row if required’ - if i uncomment this, I get different results than if I don’t (much more rows will show, but still not all of them).

    The version I am using is 6.0.20221.557. I noticed that there was an update, and I did install it and tested again but the same results.

  • Posted 11 August 2022, 1:51 am EST

    Hello Brian,

    Thank you for providing the code snippets.

    The first section of code that you have shared is mostly used for styling and setting grid’s properties but the second section of code snippet that you have shared has N numbers of unknown terms like strPotentialDenomination , currentView , coin so it will be better if you can share your stripped-down sample showing the issue or modify the attached sample replicating the issue so that we can assist you further accordingly.

    In your first code snippet you have set the owner draw mode so can you also explain how you are handling this event?

    Regards,

    Prabhat Sharma.

    FlexGridSample_Mod.zip

  • Posted 12 August 2022, 10:18 am EST - Updated 3 October 2022, 10:17 pm EST

    Here is the most stripped down version of populating the grid I could do:

    
    foreach (CoinCatalogGridModel coin in coins.ToList())
                        {
                            string strPotentialDenomination = "";
    
                            fgdNav.Rows.Count++;
                            intCurrentRow = fgdNav.Rows.Count - 1;
    
                            fgdNav.SetUserData(intCurrentRow, 0, "row" + intCurrentRow.ToString());
                            fgdNav.SetData(intCurrentRow, 6, intCurrentRow.ToString());
                            fgdNav.SetData(intCurrentRow, 7, intCurrentRow.ToString());
                            fgdNav.SetData(intCurrentRow, 8, "row" + intCurrentRow.ToString());
    
                            fgdNav.Rows[intCurrentRow].UserData = intCurrentRow.ToString();
    
                            fgdNav.Rows[intCurrentRow].IsNode = true;
    
                            fgdNav.Rows[intCurrentRow].Height = 20;
                            fgdNav.Rows[intCurrentRow].Visible = true;
                            
                            
                        }
    
                        string message = $"{coins.ToList().Count} items in list\n\n{fgdNav.Rows.Count} rows in grid";
                        MessageBox.Show(message, "Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
    
    

    The first screen shot shows that there are 234 items in the list, and the grid.rows.count reflects that.

    The second shot shows that only up to row 64 is being displayed.

    Hope that helps.

  • Posted 15 August 2022, 3:24 am EST

    Hi Brian,

    could you post the full sample code (attached as a zip file)? This would make it easier to reproduce.

    In your code snippet, you set “IsNode = true”. Maybe this causes trouble. If there is no specific need for it, then remove this line. At flat list will work without.

    Recent C1FlexGrid versions had problems with tree structures - maybe your issue is related to those. Those bugs were fixed in .566.

    Best regards

    Wolfgang

  • Posted 15 August 2022, 10:24 pm EST

    Hi Wolfgang,

    I think have found what could be the issue.

    For fun, I put the flexgrid on a usercontrol, and put that on the form and it loaded everything as it should.

    So there is something wrong (or corrupt) with the form I was putting it on when the flexgrid was added directly.

    Unfortunately I have lost a lot of time on this, and need to move forward. SInce it would seem that the problem is indeed on my end, and not in the flexgrid itself, I am going to move forward.

    I have upgraded to 566.

    Thank you for your assistance.

  • Posted 16 August 2022, 5:03 am EST

    Hello Brian,

    Thanks for the confirmation. In case you need any other help regarding C1 controls then please feel free to ask.

    @Wolfgang, thanks for your insights.

    Regards,

    Prabhat Sharma.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels