WinForms DataGrid formatting question

  • Thread starter Thread starter stoned99
  • Start date Start date
S

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.
 
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
 
Back
Top