FlexGrid for WinForms

adding a percent sign using Column.Format

  •  tshunnar said 1 year ago:

    Hello guys,

    I have a decimal column in a dataset that I want to show on the flex grid with a percent sign (%) next to it. However, I don’t want to the auto formatting to multiply the number by 100 because the field is stored in the dataset as integers between 0-100.
    I tried using Column.Format = ’0p’ or ’0%’ but this will multiply the cell by 100 which I don’t want.
    is there a way to just add % sign next to the number in each cell in the column using Column.Format??

    Thanks,

    Thaer

  •  Reeva1p said 1 year ago:

    Hello,

    You can use OwnerDrawCell event for that matter wherein you can append the % sign after cell 's Text.

            
          private void Form1_Load(object sender, EventArgs e)
            {
                c1FlexGrid1.DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw;
                c1FlexGrid1.OwnerDrawCell += new C1.Win.C1FlexGrid.OwnerDrawCellEventHandler(c1FlexGrid1_OwnerDrawCell);
            }
            void c1FlexGrid1_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
            {
                if (e.Col == IntegerColIndex && e.Row > 0)
                {
                    e.Text = e.Text + " %";
                }
            }
    

    Hope it helps.

    Thanks,
    Reeva Dhingra

    Answer
  •  tshunnar said 1 year ago:

    Thanks Reeva. It helped.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.