Hi All.
I would like to format PHONE column on DGV. For instance 1234567891 need to format like (123)456-7891. If is it possible how to do?
Thanks.
Printable View
Hi All.
I would like to format PHONE column on DGV. For instance 1234567891 need to format like (123)456-7891. If is it possible how to do?
Thanks.
see this thread for formatting ph#
http://www.vbforums.com/showthread.php?t=519707
dbasnett, thanks for replay.
If I understood link correct it is formatting for textbox and I try to formatting phone in datagridview. Any help will appraciate.
Thanks.
post the code you are having problems with.
Edit the DefaultCellStyle property of your column and in the CellStyle Builder dialogue set its Format property to the same format string as was suggested in the thread that dbasnett linked to.
Hi All.
I would like to format column PhoneHome in datagridview
But in DGV I got (Pho) neH-ome. What I did worng? Table hold PhoneHome as varchar(10).Code:Me.DataGridView.Columns("PhoneHome").DefaultCellStyle.Format = (String.Format("({0}) {1}-{2}", "PhoneHome".Substring(0, 3), "PhoneHome".Substring(3, 3), "PhoneHome".Substring(6)))
Thanks.
Hi All.
In DB PhoneHome bigint
In DGV
It works.Code:Me.DataGridView.Columns("PhoneHome").DefaultCellStyle.Format = "(###) ###-####"
But when I leave that field empty on Detail form and click SAVE button I get error message:
"Input string was not in a correct format.Couldn't store <> in PhoneHome Column. Expected type is Int64."
Does your column allow nulls? If not then you cannot leave it empty.
Hi jmcilhinney
In DB that column allow null.
Thanks.
Data Type of the field in database is of numeric type and you are inserting text value, so that is obvious. Change the data type so that it can accept text values.
"Input string was not in a correct format.Couldn't store <> in PhoneHome Column. Expected type is Int64."
Data Type of the field in database is of numeric type and you are inserting text value, so that is obvious. Change the data type so that it can accept text values.
Hi Deepak Sakpal
I did it. I changed data type bigint to varchar. But in this case
doesn't work.Code:Me.DataGridView.Columns("PhoneHome").DefaultCellStyle.Format = "(###) ###-####"
Thanks.
so do u mean it's again throwing the same error while saving?