Question for experts

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello, i'm asking this question for the third time because i got two answers
but the were no good.
i have dataGrid and one of the cell contains date. now i want that after the
user entered 2 char (2 numbers) a "/" will appear. i tried to catch it with
currentcellchanged event and by overriding a procces but the problem is that
while i'm still at the same cell when i'm cheking the text of the cell it
contains "" only when i'm moving to the next or previous cell it shows me the
right text.

now, i'm sure there's a way to do it, but which way is it???

thanks
 
Are you using a custom DataGridTableStyle? Use a custom DataGridTableStyle
where you add a GridColumnStyle for each column. For your date column, set
its GridColumnStyle to a DataGridTextBoxColumn. Then set the Format property
of DataGridTextBoxColumn for date formatting. See class DateTimeFormatInfo.

If this doesn't produce what you need, you'll have to create a class that
derives from DataGridTextBox and handle all input characters, then display
the date in the proper format.

HTH,
kevin aubuchon
 
Hi Kevin, Thanks.
yes i'm using a custom DataGridTableStyle, but i couldn't set the format as
you told me. can you give me an example?
and if i'll have to ovride do you know which procces it will be?

thanks a lot
 
hi,
If you have problem with format style then you can refer this.

Now your issue is individula column formatting.

See your code.

DataGridColumnStyle TCTransNum = new DataGridTextBoxColumn() ;

TCTransNum.MappingName = "TransNum" ;

TCTransNum.HeaderText = "Trans Number" ;

TCTransNum.Width = 65 ;

here you can set one more property that will deside in which format you can
show the content of that cell.

TCTransNum.Format="c" >>> this mean you want to show the content in
currency format which is complient to your culture info.

Like this you can show the content in different format.
If you have MSDN in your machine then please try to type the link that i
mention just below. There you will get lot of format froms. And how you need
to use that.


ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconcustomdatetimeformatstrings.htm


Please type this link in your VS.NET IDE help Url entry box.
 
i will try it,
my question now is, if by setting the format the "/" will appear automaticly?
and if not how can i do it?

thanks
 
Back
Top