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
340
How to set Cell Text conditionally
posted

I have an UltraGrid bound to a list of elements.


One of the columns is of type double.

I want to conditionally calculate a text string based on user picking this else where:

 

But cell.Text is readonly

 and 

cell.Value throws an exception, because it wont let me set a string into a double columns value.

 

How can I do this? 

 

      private void fGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
      {
               UltraGridCell cell = e.Row.Cells["ColName"];

               cell.Text = DollarFormatting.FormatDollarValue((double)value, DollarsOrPercentage.Percentage, TotalForPercentage);
      }

Parents
  • 625
    posted

    I could be wrong - but I think.....

    You want to set the value in the cell using .Value not with .Text.

    e.Rows.Cells["ColName"].Value = whatever

    The error you are getting makes sense; you should assign a double into a column that is expecting a double.  The formating you want to do shouldn't be done using a string; instead you should be using an input mask.

     

Reply Children