2

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.

Ricardo Souza
  • 16,030
  • 6
  • 37
  • 69
Igor
  • 5,620
  • 11
  • 51
  • 103
  • localhost is not an IP address, it's a string. A single control will probably not disagree both DNS names *and* IP addresses. Which one are you looking for? – Cody Gray - on strike Aug 03 '12 at 00:25
  • @CodyGray, looking for "127.0.0.1". – Igor Aug 03 '12 at 01:00
  • possible duplicate of [IP Address in a MaskedTextBox?](http://stackoverflow.com/questions/7924000/ip-address-in-a-maskedtextbox) - the MaskTextCtrl cant do it without an ugly user experience, the duplicate has your best options IMO – Jeremy Thompson Aug 03 '12 at 02:38
  • @JeremyThompson, 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? Thank you. – Igor Aug 03 '12 at 17:44

2 Answers2

1

I ended up using the text control with the Validation.

MrTux
  • 32,350
  • 30
  • 109
  • 146
Igor
  • 5,620
  • 11
  • 51
  • 103
0

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

Community
  • 1
  • 1
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • 1
    We probably talk about 2 different things. Here is what I see when I click on the "duplicate" link: "How can I use a MaskedTextBox to prevent the user from entering an invalid IP address? (I want it to behave just like the Windows one". This question is about user input. Did you make a mistake when referencing? – Igor Aug 04 '12 at 03:50
  • I'm pretty sure we are talking about the same control. Do not try and bend the spoon. That's impossible. Instead... only try to realize the truth. I have shown you the `windows one` and that this a chameleon question. – Jeremy Thompson Aug 04 '12 at 04:56