|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
WinForms DataGrid formatting questionDear .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 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. 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.
Moving Forms
Trouble with mouse click vb with odbc slightly OT: VB user base File handling in VB How to reference Webform textbox controls in a for next loop Excel problem: Cant hide column. VB.net app to run in the background How can I add jobs to the system scheduler how to compare two date variables? |
|||||||||||||||||||||||