none
Make DataGridView accept links only RRS feed

  • Question

  • I want to edit the code below so
    Make the textbox that transfers data to DatagridView accepts only links

    Also do not get out of the textbox until you place the link

    'not work
    
    TextBox4.DataBindings.Add("text", BindingSource1, "web_url", True, 1, 3)
    'not work
    
     TextBox4.DataBindings.Add("Link", BindingSource1, "web_url", True, 1, "")
    'not work
    TextBox3.DataBindings.Add("Text", BindingSource1, "web_type", True, 1, 1)
    'not work
    TextBox3.DataBindings.Add("Text", BindingSource1, "web_type", True, 1, 0)

    Wednesday, November 15, 2017 8:25 AM

Answers

  • I want to edit the code below so
    Make the textbox that transfers data to DatagridView accepts only links

    Also do not get out of the textbox until you place the link

    Hello,

    According to your description, I am not sure what you want to do. I guess that you want to validate the link in the Textbox valid or invalid url, if it is, you can transfer this data to datagridview, am I right?

    If yes, you can use the regex to check:

     Dim pattern As String
            pattern = "http(s)?://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?"
            If Regex.IsMatch(TextBox2.Text, pattern) Then
                MsgBox("Valid URL!")
            Else
                MsgBox("Invalid URL!")
            End If

    Then you can set datagridview column as datagridviewlinkcolumn:

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, November 16, 2017 6:05 AM
    Moderator