Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1871
When a row is selected can the cell format be changed.
posted

I know how to change the format on a column but is it possible to change the format on a cell by cell basis?

My data is bound to a dataset. This dataset makes the quantity datatype System.Decimal. I then do a test on each row to see what type it is

(string)e.Row.Cells["Dsp_stype"].Value

If the value is a "P" then I want my quantity  to display 0.000 or its actual value but when the row type is a "C" I want to display blank. I tried using format "#.###" and I did get the desired results for a "C" row type but type "P" gets butchered. Which I would expect considering the format is for the entire column not just the cell I am trying to manipulate.

I have tried to set the cells Active, Selected and Cell appearances ForeColor to be the same as the BackColor but once the row is selected my overrides are ignored.  According to INF support this is by default.

I have added a couple of images to show what my desired results are.

Before a comment row is selected. This is how I want it to look whether the row is selected or not.

How it looks before a row is active.

After a comment row has been selected.

Parents
  • 469350
    Suggested Answer
    Offline posted

    What I would do is hide the column and add an unbound column to the grid. You can do this in the InitializeLayout event. Then you can use InitializeRow to example the value in the real (hidden) column and populate the cell in the unbound (visible) column with whatever you like.

    If the field is updatable, you can reverse this process in the BeforeRowUpdate event.

Reply Children