How do I override the bound value displayed?

Posted by: imgodot on 8 September 2017, 3:17 pm EST

  • Posted 8 September 2017, 3:17 pm EST

    I have a datatable bound to a Spread.
    One column in the datatable contains dates.
    Some of those dates are 1/1/1900.
    When the data is loaded into the spread, we want to display "XXX" for the dates that are 1/1/1900.

    In the COM version of Spread there was the DataFill event.
    How do I achieve this in Spread 8 for winforms?

    Thanks.
  • Replied 8 September 2017, 3:17 pm EST

    Hello,

    You can try using DataColumnConfigure event for that matter as given in link below:-

    http://helpcentral.componentone.com/NetHelp/SpreadNet8/WF/webframe.html#FarPoint.Win.Spread~FarPoint.Win.Spread.FpSpread~DataColumnConfigure_EV.html

    Hope it helps.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:17 pm EST

    Thank you for the suggestion.

    However, DataColumnConfigure allows me to configure the cell-type, etc. for an entire COLUMN, but my question is how do I change the value that is displayed in a cell on a cell-by-cell basis?

    E.g. The date values in my column can be any date value, but some of them are "1/1/1900".
    For those dates that are "1/1/1900" we want to display "XXX".

    The code we are porting is from VB6 and Spread 6, and Spread 6 has this capability, but I do not see how to do it in Spread 8. Does Spread 8 have this functionality?

    Thanks.

    -- Paul

  • Replied 8 September 2017, 3:17 pm EST

    Hello?
  • Replied 8 September 2017, 3:17 pm EST

    Reeva, Thanks for the reply.

    Let me explain our situation in a little more detail.
    We have a grid bound to a bindingsource linked to a typed datatable.
    The grid is only for display purposes and NOT for data entry.
    We really want the grid to be read-only (though scrollable).

    In my previous example, we want to force a date of 1/1/1900 to display as a string = "XXXX".
    However, we found no way to do that and you suggested we use the Paint event.
    We tried that and it throws an exception when we try and set the date column to a text value.
    Also, we really would NOT want to use the Paint event anyway. It's pretty gross to loop through the rows and columns every time the grid is re-displayed/re-painted.

    We got around the immediate issue by hiding the original column, adding an unbound column and then populating the unbound column with our "final" display value.
    Unfortunately, in some of our "read-only" grids we not only change column values but we do so in spanned cells and that fails miserably.

    I'm hoping someone has some method to allow this kind of flexibility; we had it in Spread 6 for heaven's sake.

    Help Mr/Ms Wizard!
  • Replied 8 September 2017, 3:17 pm EST

    Hello,

    Please go through these links for the same:-

    http://sphelp.grapecity.com/forums/topic/datetimecelltype-with-dynamic-dates/
    http://sphelp.grapecity.com/forums/topic/overwriting-bound-cell-value/

    Hope it helps.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:17 pm EST

    Reeva,

    Neither of those two links provided any help.
    The first talked about using formulas and was nothing like our situation.
    The second suggested adding another data layer between our datasource and Spread.

    Can anyone with knowledge of using Spread 8 provide any help?

    -- Paul
  • Marked as Answer

    Replied 8 September 2017, 3:17 pm EST

    Hello,

    Unfortunately, I tried to override bound DateTime column and I am unable to do so.

    The only workaround which i can think of if to create an unbound column by copying data of bound column and then override dates which you want to and hide the bould column.

    That seems to be only workaround I can think of.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:17 pm EST

    Reeva, Thanks.

    It's truly a shame that simple functionality in Spread 6 has been lost.

    -- Paul
  • Replied 8 September 2017, 3:17 pm EST

    Hello,

    Unfortunately, there is no equivalent of DataFill event in Spread.Net.

    However, you can try using Spread's Paint event as given below for that matter:-

            
    void fpSpread1_Paint(object sender, PaintEventArgs e)
    {
    for (int i = 0; i < fpSpread1.ActiveSheet.RowCount; i++)
    if (fpSpread1.ActiveSheet.Cells[i, 2].Text =="6")
    {
    fpSpread1.ActiveSheet.Cells[i, 2].Text = "66666";
    }
    }


    This seems to be only solution we have.

    Thanks,
    Reeva
Need extra support?

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

Learn More

Forum Channels