Phone number format in display member?


Author
Message
Andria Jensen
Andria Jensen
StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)
Group: Forum Members
Posts: 336, Visits: 497
I am trying to put a formatted phone number in part of the drop-down's display value, and am having no luck.  In the ComboBox's PopulationDataSourceSettings dialog, I can set a display member format string.  What would I put in here to make "1234567890" display as "(123) 456-7890"?  I know you can use things like {0:c} to display currency or {0:d2} to display a given precision, and so on.  I'm just at a loss as to what I can use here to display a phone number.  Also, one other thing to consider is international numbers.  What if this number is formatted differently for different instances?
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I would populate that column through an event and then use a RegEx pattern to split the phone number into parts.  For example, your pattern and replacement would look something like this:

Imports System.Text.RegularExpressions

MsgBox(Regex.Replace("1231234567", "(\d{3})(\d{3})(\d{4})", "($1) $2-$3"))


Andria Jensen
Andria Jensen
StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)
Group: Forum Members
Posts: 336, Visits: 497
I may be asking a stupid question, but how do you populate a specific part of the display through an event?
Michael Reese
Michael Reese
StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
I believe you can place in the validation event so it would perform the update following entry. By the way, Infragistics has one that will preformat prior to entry and even allow for extensions!
Andria Jensen
Andria Jensen
StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)
Group: Forum Members
Posts: 336, Visits: 497
This is actually a DevExpress inherited combo box.  Not sure how to do it with this one.  I know how you can do this with the grid on the CustomColumnDisplayText, but it's not quite the same with the combo.
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Every control has a DataBindings collection... the first element of which should contain the Binding object that we create and attach to the control.  The Binding object itself has a Format event that is raised when the data is being copied into the control.  You can handle the Format event and modify the value within the event args and programmatically change the value that is being sent to the control.

You'll also have to bind to the DataBindings.CollectionChanged event so you attach to the Format event of any new binding that is added to the collection.  For an example on how to do this, you can check the Infragistics wrapper's UltraDateTimeEditor... I had to handle the Format to get the date to display NULL values properly.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search