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. Image for the cookie policy date

Translating values in Datagrid

My database stores 'F', 'S', 'P' values in a particular DB(Database) field. I want to display them as follows; DB Value Display As ======================================= 'F' ----> Finished Product 'S' ----> Semi Finished Product 'P' ----> Part Can any one please tell me how to achieve this.

3 Replies

CB Clay Burch Syncfusion Team June 25, 2002 11:44 AM UTC

One way you could try to do this is to derive a custom columnstyle. In your derived class, override GetColumnValueAtRow and Commit. In the get override, call the baseclass, and then depending upon whether the value is F, etc, change it to your long name. In your commit override, change the long name to your short name before calling the baseclass. Take a look at this Microsoft KB article, HOW TO: Extend the Windows Form DataGridTextBoxColumn Control to Custom-Format Data (Q318581). It subclasses a DataGridColumnStyle and overrides both GetColumnValueAtRow and Commit to implement this behavior.


VB Vipul Bhatt June 25, 2002 12:59 PM UTC

> One way you could try to do this is to derive a custom columnstyle. In your derived class, override GetColumnValueAtRow and Commit. In the get override, call the baseclass, and then depending upon whether the value is F, etc, change it to your long name. In your commit override, change the long name to your short name before calling the baseclass. > > Take a look at this Microsoft KB article, HOW TO: Extend the Windows Form DataGridTextBoxColumn Control to Custom-Format Data (Q318581). It subclasses a DataGridColumnStyle and overrides both GetColumnValueAtRow and Commit to implement this behavior. Hi Clay.Thanx for your reply. I am new to .net and class fundas.Can you please elaborate or if you can tell me where can i find more info on how to do this. THANX A LOT.


CB Clay Burch Syncfusion Team June 25, 2002 05:41 PM UTC

The Mircosoft article is a step by step tutorial showing how to add CR to negative numbers in a datagrid. You should do that sample, but instead of adding CR in the GetColumnValueAtRow override, change the value from 'F' to 'Fxxxxx' etc. In the Commit override, instead of stripiing the CR off, you would change 'Fxxxx' to 'F'. So, the Microsoft KB should allow you to get a customcolumnstyle. To see how to use it, you can take a look at this sample which uses a custom columnstyle to restrict input to digits. George Shepherd's Windows Forms FAQ contains an entry entitled: How can I restrict the keystrokes that will be accepted in a column of my datagrid? Check it out at: http://www.syncfusion.com/faq/winforms/search/755.asp

Loader.
Live Chat Icon For mobile
Up arrow icon