We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Leading numbers in column

Thread ID:

Created:

Updated:

Platform:

Replies:

49454 Sep 19,2006 09:53 AM Sep 20,2006 07:40 AM Windows Forms 4
loading
Tags: Grouping
Karsten Brocksieper
Asked On September 19, 2006 09:53 AM

Hello,

in one of my colums in a GGC I have numbers from 10 to 100000.
Is it possible with the Format-property or with another way that I "fill up" every number with less than six characters to a number with at least six characters whereby I want to fill these numbers with leading "0" up to six characters.
For example:

10 ===> 000010
122 ===> 000122
12456 ===> 012456
123456 ===> 123456 (no change)

Thank you very much for any help

Karsten

Administrator [Syncfusion]
Replied On September 20, 2006 01:32 AM

Hi Karsten,

To specify a format on a cell, you can set style.Format and style.CellvalueType for the cell (or column in a GridDataBoundGrid or GridGroupingControl). But this will only display the problem when your user leaves the cell. It will not prevent him from typing anything. The Format property works with TextBox celltype only. Below is a code snippet

this.grid.TableDescriptor.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CellType = "TextBox";
this.grid.TableDescriptor.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CellValueType = typeof(int);
this.grid.TableDescriptor.Columns["ColumnName"].Appearance.AnyRecordFieldCell.Format = "000000";

Let me know if you are looking something different.

Thanks,
Haneef

Karsten Brocksieper
Replied On September 20, 2006 04:37 AM

Hi Haneef,

thank you for your response. But my problem is not to prevent the user from typing anything into the cell.
My problem is just to show (NO INPUT in the cell at all) the numbers in the cells with leading "0".
I fill the GGC with a datatable from an access database and in the underlying table there are the values without leading "0". And the only wish I have is to show the values in the GGC with leading "0".

Thank you very much for your help.
Karsten

>Hi Karsten,

To specify a format on a cell, you can set style.Format and style.CellvalueType for the cell (or column in a GridDataBoundGrid or GridGroupingControl). But this will only display the problem when your user leaves the cell. It will not prevent him from typing anything. The Format property works with TextBox celltype only. Below is a code snippet

this.grid.TableDescriptor.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CellType = "TextBox";
this.grid.TableDescriptor.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CellValueType = typeof(int);
this.grid.TableDescriptor.Columns["ColumnName"].Appearance.AnyRecordFieldCell.Format = "000000";

Let me know if you are looking something different.

Thanks,
Haneef

Administrator [Syncfusion]
Replied On September 20, 2006 06:57 AM

Hi Karsten,

You can handle the QueryCellFormattedText event of the grid and set the e.Text to some formatted value to want to display. Below is some code snippet.

private void QueryCellFormattedText(object sender, GridCellTextEventArgs e)
{
GridTableCellStyleInfo style = e.Style as GridTableCellStyleInfo;

if( style != null && style.TableCellIdentity.Column != null
&& style.TableCellIdentity.Column.Name == "Col1" )
{
Element el = style.TableCellIdentity.DisplayElement;
if( el.Kind == DisplayElementKind.Record )
{
if( e.Value == null || e.Value.ToString() == string.Empty )
e.Text = "000000";
else
e.Text = string.Format("{0:000000}",e.Value);
e.Handled = true;
}
}
}

Sample : http://www.syncfusion.com/Support/user/uploads/GGCUpdate_e364cdc8.zip

Thanks,
Haneef

Karsten Brocksieper
Replied On September 20, 2006 07:40 AM

Hi Haneef,

...thank you very much for your help. That is exactly what I was searching for.

Regards,
Karsten

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;