Igor
Igor

Reputation: 6255

Use maskedtextctrl for IP address in C#

ALL,
I have a very simple WinForms application with C#.NET.
In there I need the control for entering an IP address, so I used MaskedTextCtrl.
This control needs to have a default value of localhost, i.e. the value should be there when the program starts, so I use "Text" property of the control.

I set the mask to be "999.999.999.999" and the text to "127.0.0.1", which converts to "127001" and it displays incorrectly in the GUI designer and when the program starts.

What can I do to make it work?

Thank you.

Upvotes: 2

Views: 2380

Answers (2)

Igor
Igor

Reputation: 6255

I ended up using the text control with the Validation.

Upvotes: 1

Jeremy Thompson
Jeremy Thompson

Reputation: 65564

I heed your comments:

This is not a duplicate. It's talking about user entering IP address. What I'm talking is have an IP address pre-populated and displayed. In fact I think "MaskedTextBox" is not suitable for that. Can you prove otherwise?

But the duplicate is asking the same thing with code and also UI.

enter image description here

Edit: I did search for a control before I posted a comment and Telerik seem to have something along these lines. I also saw some problems with it too

Upvotes: 0

Related Questions