FlexGrid: simply save and restore the layout

Posted by: andreas.kren on 13 June 2018, 12:42 pm EST

    • Post Options:
    • Link

    Posted 13 June 2018, 12:42 pm EST

    With TrueDBGrid it is rather easy. With flexGrid I just cant find howto save the layout of the columns (order, width, … ) the user has made and then restore it

    Please help.

  • Posted 13 June 2018, 1:42 pm EST

    Found “BuildString” and “ParseString” methods in the “cols” collection.

    Not very intuitive, no mentioning in the doc… :-/

  • Posted 14 June 2018, 4:30 am EST

    Hi,

    those methods might do too much, because they contain the full column definitions. If you add new columns in the app (or change e.g. the data type), then old user settings might kill those new columns. Better don’t use those methods for layout persisting ;-).

    You will have to use custom code to achieve this.

    Best regards

    Wolfgang

  • Posted 14 June 2018, 4:46 am EST

    Hello!

    Thanks Wolfgang.

    And yes Andreas, BuildString and ParseString methods of C1FlexGrid are used to save and restore complete description of the column collection. Here are the corresponding help links :

    1. BuildString

      http://help.grapecity.com/componentone/NetHelp/c1flexgrid/webframe.html#C1.Win.C1FlexGrid.4~C1.Win.C1FlexGrid.ColumnCollection~BuildString.html
    2. ParseString

      http://help.grapecity.com/componentone/NetHelp/c1flexgrid/webframe.html#C1.Win.C1FlexGrid.4~C1.Win.C1FlexGrid.ColumnCollection~ParseString.html

    However, please take care of the additional point mentioned by Wolfgang while using these.

    Furthermore, I would like to suggest you another way to save and restore layouts (a workaround that may suit your requirements) :

    1. Save the grid as XML file.
       c1FlexGrid1.SaveGrid(@"..\..\Layout.xml", FileFormatEnum.Excel, FileFlags.OpenXml);
    
    1. Restore layout only from the saved file (not the grid data).
        c1FlexGrid1.LoadGrid(@"..\..\Layout.xml", FileFormatEnum.Excel, FileFlags.OpenXml);
        c1FlexGrid1.Clear(ClearFlags.Content);
        c1FlexGrid1.Clear(ClearFlags.UserData);
    

    In case you face any issue, please let us know.

    Best regards,

    Meenakshi

  • Posted 14 June 2018, 4:56 am EST

    Hi Meenakshi,

    thank you for your answer.

  • Posted 14 June 2018, 4:57 am EST

    Hallo Wolfgang, jederzeit auch gerne direkt auf Deutsch, andreas.kren@wizardsoftware.at. Du scheinst ja jede Menge Erfahrung mit C1 zu haben. Die Geschwindigkeit des Supports läßt mich als Mitteleuropäer, der , wenn überhaupt, weil Kundeneinsatz, dann jetzt, etwas braucht ein bisschen verzweifeln.

    For the rest. I (most often) just need simple column layout saving (buildstring(false)) and restoring and thats working.

    Thank you Wolfgang

  • Posted 15 June 2018, 8:08 am EST

    Tja, wir haben leider keinen Platinsupport dazugekauft :-(. Aber der Support ist deutlich besser als vor ein paar Jahren, mittlerweile bekommt man innerhalb eines Tages brauchbare Hilfe ;-).

    Wolfgang

Need extra support?

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

Learn More

Forum Channels