473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

WinForms DataGrid formatting question

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.

Oct 10 '06 #1
2 1003
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.
Oct 11 '06 #2
I found this microsoft article that described a solution:

http://support.microsoft.com/default...;en-us;Q318581
rowe_newsgroups wrote:
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.
Oct 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kk | last post by:
..NET Winforms Control for Spell and grammar check with formatting capabilitie ------------------------------------------------------------------------------------------- Need a control which has...
5
by: John Spiegel | last post by:
Hey all, I have contusions and I think a minor concussion after trying to find information on advanced WinForms DataGrid use. Does anyone know of a site / book that gets really in-depth on the...
5
by: BBFrost | last post by:
Win2000 ..Net 1.1 SP1 c# using Visual Studio Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1 datagrid. I've come to realize that a 'block' of rows highlighted within...
4
by: David Krmpotic | last post by:
Hello, Can please tell me how to do it ? This should be simple, because I'd think it's used a lot.. but in reality is not that simple and there is at least 50 topics about it in newsgroups,...
5
by: AC | last post by:
Any reason i'm having trouble with: DataGrid1.Columns(7).ItemStyle.HorizontalAlign = HorizontalAlign.Right I'm trying to directly set the column alignment of a datagrid created at runtime.. ...
7
by: Matthew Wieder | last post by:
Hi - I have a datagrid that has a black header and the rows alternate white and gray. The problem is that until items are added to the grid, the grid appears as a large black rectangle, which is...
4
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
13
by: pmcguire | last post by:
I have a DataGrid control for which I have also created several new extended DataGridColumnStyles. They behave pretty nicely, but I can't figure out how to implement Selected Item formatting for...
3
by: Tom S. | last post by:
VS.Net 2003 V 7.1.3088 ..Net Framework V 1.1.4322 SP1 WinXP SP2 I have a WinForms project that I'm having trouble with. I have a custom user control ( all code based, no visual ) and another...
1
by: TonyJ | last post by:
Hello! If there is a datagrid in VS2005 for winforms what kind of datagrid is it then. 1.Is it a bound datagrid that has a direct connection to columns for tables in the database. 2. Is it an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.