Results 1 to 2 of 2

Thread: [2.0] custom format column datagridview

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    [2.0] custom format column datagridview

    in a datagrid view, if I add a custom row (not binding to anything at all):

    Code:
    this.theDataGridView.Columns.Add("Value", "Value");
    this.theDataGridView.Columns.Add("Name", "Name");
    
    string[] rows = new string[2];
    rows[0] = "5.236";
    rows[1] = "blah";
    
    this.theDataGridView.Rows.Add(rows);
    how can I set the format of the value column?

    I know that this works:

    this.theDataGridView.Columns["Value"].DefaultCellStyle.Format = "#.##";

    but only when you are binding to a datasource, such as SQL.

    If I apply this at any point in the code, it still does not format the column, to give me the format as follows:

    x.xx -> 5.23

    any ideas?

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: [2.0] custom format column datagridview

    yes I believe I solved it, pretty obvious: incorrect data format!

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

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