Home All Groups Group Topic Archive Search About

WinForms DataGrid formatting question

Author
10 Oct 2006 8:25 PM
stoned99
Dear .NET experts:

Hi, I have a table bound to a grid with a column that can contain
either SSN or TAX-ID. Based upon the content of the cell I want to
apply either the mask 00-00000 or 000-00-0000. I can only figure out
how to apply a single mask for all rows for the specific column. How do
I change the mask based upon the cells content.

I appreciate any help that you can offer.

Author
11 Oct 2006 12:43 AM
rowe_newsgroups
You could just write your own method to do this. Here's an example
using a textbox that you should be able modify to fit your needs.

        If TextBox1.Text.Length = 7 Then
            TextBox1.Text = Mid(TextBox1.Text, 1, 2) & "-" &
Mid(TextBox1.Text, 3, 4)
        ElseIf TextBox1.Text.Length = 9 Then
            TextBox1.Text = Mid(TextBox1.Text, 1, 3) & "-" &
Mid(TextBox1.Text, 4, 2) & "-" & Mid(TextBox1.Text, 7, 4)
        End If

Thanks,

Seth Rowe


stoned99 wrote:
Show quoteHide quote
> Dear .NET experts:
>
> Hi, I have a table bound to a grid with a column that can contain
> either SSN or TAX-ID. Based upon the content of the cell I want to
> apply either the mask 00-00000 or 000-00-0000. I can only figure out
> how to apply a single mask for all rows for the specific column. How do
> I change the mask based upon the cells content.
>
> I appreciate any help that you can offer.
Author
11 Oct 2006 3:13 PM
stoned99
I found this microsoft article that described a solution:

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q318581


rowe_newsgroups wrote:
Show quoteHide quote
> You could just write your own method to do this. Here's an example
> using a textbox that you should be able modify to fit your needs.
>
>         If TextBox1.Text.Length = 7 Then
>             TextBox1.Text = Mid(TextBox1.Text, 1, 2) & "-" &
> Mid(TextBox1.Text, 3, 4)
>         ElseIf TextBox1.Text.Length = 9 Then
>             TextBox1.Text = Mid(TextBox1.Text, 1, 3) & "-" &
> Mid(TextBox1.Text, 4, 2) & "-" & Mid(TextBox1.Text, 7, 4)
>         End If
>
> Thanks,
>
> Seth Rowe
>
>
> stoned99 wrote:
> > Dear .NET experts:
> >
> > Hi, I have a table bound to a grid with a column that can contain
> > either SSN or TAX-ID. Based upon the content of the cell I want to
> > apply either the mask 00-00000 or 000-00-0000. I can only figure out
> > how to apply a single mask for all rows for the specific column. How do
> > I change the mask based upon the cells content.
> >
> > I appreciate any help that you can offer.