This is a migrated thread and some comments may be shown as answers.

Radgridview Column formating at design time

6 Answers 411 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hasan
Top achievements
Rank 1
Hasan asked on 30 Jan 2011, 05:35 PM
How you can define a date time column FormatString property at design time to show only date in the column and not the time. If it is not possible at design time what is the way to do it in vb.

6 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 30 Jan 2011, 07:00 PM
Hi Hasan,

In code:
dateColumn.FormatString = "{0:d}"

See MSDN for Format String Info

In the Designer

      • Go to the properties of the RadGridView
      • Open the Columns collection editor
      • Find or add your date time column
      • Set the Format String to "{0:d}"

Hope that helps
Richard

EDIT: Note that you can also set the same information through the Smart Tag >> Open Property Builder

0
Hasan
Top achievements
Rank 1
answered on 06 Feb 2011, 12:45 PM
Thanks for the help. It is showing the correct date format but when I export the data in pdf it is still showing the date time format. How to fix that.
0
Richard Slade
Top achievements
Rank 2
answered on 06 Feb 2011, 08:57 PM
Hello,

Please have a look at the following forum post which explains formatting PDF date columns.
Hope that helps
Richard
0
Jennifer
Top achievements
Rank 1
answered on 11 May 2012, 04:32 PM
I have an unbound data grid that I fill with data.  I also allow users to modify the data.
The columns I am interested in contain US currency and percentage.  I have opened up the property builder and added the format {0:c} (and various others) to the FormatString property to get the deesired effects.  I also tried setting the property in code as well; that didn't work either.

I cannot get the currency (or percentage) to display in the columns.
Can someone help me determine what I am doing wrong?

Thanks!
Bob
0
Bob
Top achievements
Rank 2
answered on 11 May 2012, 04:34 PM
Wrong email / Account - Sorry.

I have an unbound data grid that I fill with data. I also allow users to modify the data.
The columns I am interested in contain US currency and percentage. I have opened up the property builder and added the format {0:c} (and various others) to the FormatString property to get the deesired effects. I also tried setting the property in code as well; that didn't work either.

I cannot get the currency (or percentage) to display in the columns.
Can someone help me determine what I am doing wrong?

Thanks!
Bob
0
Stefan
Telerik team
answered on 16 May 2012, 02:14 PM
Hello,

Thank you for writing.

Here is a small example which demonstrates how to set the FormatString of a decimal column to both currency and percentage:
public Form1()
{
    InitializeComponent();
 
    GridViewDecimalColumn col1 = new GridViewDecimalColumn("Currency");
    col1.FormatString = "{0:c}";
    radGridView1.Columns.Add(col1);
     
    GridViewDecimalColumn col2 = new GridViewDecimalColumn("Percentage");
    col2.FormatString = "{0:p}";
    radGridView1.Columns.Add(col2);
 
    for (int i = 0; i < 10; i++)
    {
        radGridView1.Rows.Add(i * 3.14, (double)i/10);
    }
}

I hope this helps.
 
All the best,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Hasan
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Hasan
Top achievements
Rank 1
Jennifer
Top achievements
Rank 1
Bob
Top achievements
Rank 2
Stefan
Telerik team
Share this question
or