How to replicate a complete row, which has cells with particular behaviors?

Posted by: desarrollo.netsw on 30 August 2018, 10:45 am EST

    • Post Options:
    • Link

    Posted 30 August 2018, 10:45 am EST - Updated 30 September 2022, 5:11 am EST

    Hello! I am new with Spread, and I am practicing with the trial version, to implement the UserControl in my business applications.

    To explain what I am trying to do, I will give a reference example. Suppose we have a material with some particular composition, which we can take as reference to catalog other similar materials. A base material could be iron, and its properties could be its hardness, its mass, etc. Now, we have a sample of iron, which varies subtly from the base iron, and we want to know these differences through colors in the cells.

    The only row that has the grid that I have made, has 7 columns. The first column contains a simple description, from columns 2 to 4 are the properties of the new material, and from column 5 to 7 the properties of the base material.

    In the cell corresponding to Prop1 I defined a Formatting Condition, in which, if the value of Prop1 is different from the value of Prop1_Ref, it is painted red. This behavior is analogous to Prop2 with Prop2_Ref, and Prop3 with Prop3_Ref.

    Now I finally ask my question: How can I add successive rows that replicate the exact behavior of the example row? Or is the only way to replicate the generated source code?

    The rows will be loaded programmatically, I will take objects from my business layer to set the base values ​​(Description and Prop1_Ref, Prop2_Ref, Prop3_Ref).

    I attach the solution in WinForms.

    Thank you very much!

  • Posted 30 August 2018, 8:13 pm EST

    Hello,

    You can use ClipboardCopyOptions & ClipboardPasteOptions options for the same as given in documentation links below which specifies what can be copied and what can be pasted to cells on copy pasting entire row:-

    http://help.grapecity.com/spread/SpreadNet11/WF/webframe.html#FarPoint.Win.Spread~FarPoint.Win.Spread.ClipboardCopyOptions.html

    http://help.grapecity.com/spread/SpreadNet11/WF/webframe.html#FarPoint.Win.Spread~FarPoint.Win.Spread.ClipboardPasteOptions.html

    Hope it helps.

    Thanks,

    Reeva

  • Posted 2 September 2018, 3:19 am EST

    Hello Reeva, thank you very much for your help!

    I found another way to establish the behavior in a generic way: I set a Conditional Format for the columns; I could even do it with a single rule for all the columns, it’s perfect.

    Now I have another question: how can I fill my grid using IList? In all the tests that I did, when performing the binding, the entered data ignore the Conditional Formatting, even the CellType defined by column.

    I tried to define the DataField property in the Spread Designer, but the field is read-only.

    I was able to fill the grid cell by cell, it works fine, but I find it inpractical, since my business layer returns objects.

    Thank you.

    Spread Conditional Formatting.zip

  • Posted 4 September 2018, 9:07 pm EST

    Hello,

    You can set the DataSource and DataField for Spread as shown in the documentation here;

    http://help.grapecity.com/spread/SpreadNet11/WF/webframe.html#spwin-databind-field.html

    Thanks,

    Deepak Sharma

  • Posted 5 September 2018, 12:15 am EST

    Hello Sharma,

    Thank you for your assistance. I have already tried the solutions you propose.

    If I use DataSet, then I have to convert my data from Objects to DataSet; in this case I have to add extra logic to convert the data from my business model (which is in objects) to DataSet, and the reverse when interpreting the data in the grid.

    In any case, using DataSet, or using IList, when I fill the grid, I lose elements defined in the grid such as the Formatting Conditions.

    So far, the only solution that has worked for me is filling cell by cell. This involves considerable effort.

    Any proposal is welcome. In my previous answer I attached a project with the proposed scenario.

    Thank you.

  • Posted 10 September 2018, 8:12 pm EST

    Hello,

    You can set the DataSource for DefaultSheetDataModel of Spread, e.g.

    ArrayList values = new ArrayList();
    values.AddRange(new Object[] {"Ace", "King", "Queen", "Jack"});
    FarPoint.Win.Spread.Model.DefaultSheetDataModel dataModel = new FarPoint.Win.Spread.Model.DefaultSheetDataModel(values,typeof(string));
    fpSpread1.ActiveSheet.Models.Data = dataModel;
    

    Thanks,

    Deepak Sharma

Need extra support?

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

Learn More

Forum Channels