Click here to Skip to main content
15,668,342 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I am using VS2015 Windows Forms Applications. With my form I have a masked textbox control, used to read date like "dd/MM/yyy" format. And when I set mask "##/##/####" the maskedtextbox control appear like " / / " . So that the user can enter date,month,year, and no need to enter "/". Similar way I wish to read time column in datagridview like "hh:mm". means...the ":" (Colan) has to display automatically and when the user enter the value, first 2 digit for hours and the second 2 digit for minutes. Is it possible?

Actually I tried by following codes, but no use...Is it possible to get help.. Thanks

this->myDataGrid1->Columns[17]->DefaultCellStyle->Format = "##:##"

What I have tried:

I tried to mask the datagridview column by "##:##" format.
Updated 26-Dec-19 8:46am

1 solution

Try something like this:
dataGridView1.Columns["MyTime"].DefaultCellStyle.Format = "hh:mm";

Or use this trick for using a MaskedTextBox column: DataGridViewColumn Hosting MaskedTextBox[^]
Share this answer
Paramu1973 27-Dec-19 3:22am    
Hi RickZeeland, I found your link will be useful. But is it possible to use that ExtendedControls.dll for other Languages? Thanks
RickZeeland 27-Dec-19 4:36am    
Yes, in a .NET solution you can mix e.g. VB.NET and C# projects, so that should be no problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900