CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Posts
    28

    DataGridViewRow Problem (Formatting not updating)

    I am having problems with my DataGridView.

    I have two colums in this row. Text, and Cost. In the cost Column, I have the DefaultCellStyle Format set to C2 (As a number).

    When I add rows (DataGridView.Rows.Add("Text", "5")), it formats it correctly as $5.00 (In the Cost Column).

    The problem I am having is on an update. I want to be able to format the row correctly when a user edits the row. When I edit the row, DataGridView_CellEndEdit shows me the value "5", but not the correctly formatted value, nor can I update the format for the user.

    How would I update the format?

  2. #2
    Join Date
    Apr 2010
    Posts
    131

    Re: DataGridViewRow Problem (Formatting not updating)

    Something like myDataGridView(int col,int row).Value = String.Format("{0:C}", myDataGridView(int col, int row).Value)
    ???

  3. #3
    Join Date
    Sep 2006
    Posts
    28

    Re: DataGridViewRow Problem (Formatting not updating)

    Would this go into the Cell Validating Method, or CellEndEdit.

    I just don't understand why it doesn't update the format. The Cell Inherited style should see that it should be formatted as "C2", don't understand why I have to manually update it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured