Re: IP Textbox User Control
That looks ideal! How do I add that custom control to my project?
Re: IP Textbox User Control
From your project just select "Add existing item" and find the IPTextBox.vb file from my project. Once you add it to your project, build your project and the control will appear in your toolbox.
Re: IP Textbox User Control
Firstly Great stuff!! I tried to create a IP masked textbox in VB2005 using 099.099.099.099 but this didn't quite give me the result I was looking for.
Couple of suggestions for this but it could be what you mean by user controls.
1, When a . is pressed it moves to the next box or a backspace on the last char in a box moves you to the last box
2, Copy and paste function - ability to copy the content or paste content in
If you could point me in the right direction that would be much appreciated
Thanks
Re: IP Textbox User Control
Fixed the when you press a dot it tabs I used
VB Code:
Private Sub txtIP_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtIP1.KeyPress, txtIP2.KeyPress, txtIP3.KeyPress, txtIP4.KeyPress
Dim txtBox As TextBox = DirectCast(sender, TextBox)
'ONLY ALLOW CONTROL CHARS (LIKE BACKSPACE) AND NUMBERS TO BE ENTERED
Select Case Char.GetUnicodeCategory(e.KeyChar)
Case Globalization.UnicodeCategory.Control, Globalization.UnicodeCategory.DecimalDigitNumber
Case Else
e.Handled = True
End Select
Debug.Print(e.KeyChar.ToString)
If e.KeyChar = "." Then
Me.SelectNextControl(txtBox, True, True, False, False)
End If
End Sub
Still not sure about the copy paste tho..
Re: IP Textbox User Control
do you mean copy/paste an entire IP into the box?
Since the user control was build to behave like the windows IP entry box, it is actually made up of 4 textboxes. So you can't copy/paste an entire IP. (you could, but you would have to write more code to look at a paste, see if its a full valid IP, and then fill in each of the 4 textboxes)
1 Attachment(s)
Re: IP Textbox User Control
I know thats the way the windows one acts but, it would be useful to copy and paste details as well as having the "." and the backspace function
I have made some adjustments to the project feel free to take a look
:)
Re: IP Textbox User Control
Very nice indeed.
Can I give a suggestion ( use it / don't use it )
Why not make it so that you cannot enter 0 0 0 0 or 255 255 255 255 which an IP address cannot be. ¿
Re: IP Textbox User Control
Quote:
Originally Posted by HanneSThEGreaT
Very nice indeed.
Can I give a suggestion ( use it / don't use it )
Why not make it so that you cannot enter 0 0 0 0 or 255 255 255 255 which an IP address cannot be. ¿
Actually in Windows when it's obtaining an ip address or you use 'IpConfig /Release' The system's IP is '0.0.0.0' and 255.255.255.255 is a valid ip, it's just not one you see
Re: IP Textbox User Control
Thanks guys for the good suggestions.
I think its really up to the user of the this feature as to whether they have some kind of validation on the values.
Cheers ;)
Re: IP Textbox User Control
Ok, assuming I'm an idiot, how do I add this to my program?
Re: IP Textbox User Control
which version of Visual Studio?
Re: IP Textbox User Control
One more thing. How you add the functionality so that when the user presses ENTER it will run some sub/function?
Re: IP Textbox User Control
I have added this sub as a new private sub, so every time you type Enter the current textbox transfers you to the next one.
vb Code:
Private Sub txtIP_KeyDown(ByVal sender As System.Object, ByVal e As KeyEventArgs) Handles txtIP1.KeyDown, txtIP2.KeyDown, txtIP3.KeyDown, txtIP4.KeyDown
Dim txtBox As TextBox = DirectCast(sender, TextBox)
If e.KeyCode = Keys.Enter Then
Me.SelectNextControl(txtBox, True, True, False, False)
End If
End Sub
Re: IP Textbox User Control
Thanks very much for this component! It was very useful to control any input ip entry.
I'm glad to meet people that makes our lives easy :)
Thanks again kleinma :):)
Re: IP Textbox User Control
Hi!
Just stopping in to say i like the custom control!
I know this is an old thread, but i was wondering how can you change the default values on this, i would like to see all blanks instead of 255.255.255.255