none
Injecting URL + text into menustrip item using my.settings data? VB.NET (VS2017community) RRS feed

  • Question

  • So I'll try to explain as best as I can. 

    I have one main form (MainWin.vb), which have a menustrip with the name Menustrip1.

    Menustrip1 have a menu option called "Websites" with pre-defined websites, such as work tools etc. But it also have an option that opens a secondary submenu called "Custom".

    Under custom I've made 5 additional options called "Custom URL 1" , 2 ,3, 4, 5. 

    The code for each of these items are:

        Private Sub menCustom1_Click(sender As Object, e As EventArgs) Handles menCustom1.Click
            Dim urlCustom1 As String = ""
            Process.Start(urlCustom1)
        End Sub
    
        Private Sub menCustom2_Click(sender As Object, e As EventArgs) Handles menCustom2.Click
            Dim urlCustom2 As String = ""
            Process.Start(urlCustom2)
        End Sub
    
        Private Sub menCustom3_Click(sender As Object, e As EventArgs) Handles menCustom3.Click
            Dim urlCustom3 As String = ""
            Process.Start(urlCustom3)
        End Sub
    
        Private Sub menCustom4_Click(sender As Object, e As EventArgs) Handles menCustom4.Click
            Dim urlCustom4 As String = ""
            Process.Start(urlCustom4)
        End Sub
    
        Private Sub menCustom5_Click(sender As Object, e As EventArgs) Handles menCustom5.Click
            Dim urlCustom5 As String = ""
            Process.Start(urlCustom5)
        End Sub

    Now moving on to the Option.vb form. I have 2 textboxes created and a button. 

    Now what I'm trying to do is to have five text fields, each with a button connected to its textforms. And if you type in an url into the first textbox and a name in the second textbox, hit OK it should save the url into my.settings AND set the url into the corresponding "Dim urlCustom4 as String = "URLHERE" along with changing the name on the menu item.

    Is this doable? 


    //Regards, Andreas

    Tuesday, July 25, 2017 7:40 AM

Answers

  • I found out myself. It's probably not best practice but it worked!

    If anyone else stumbles upon this; 

    You connect the Menustrip item with a propertybinding to text. 

    And the url part you connect to the textbox :) Simple as


    //Regards, Andreas

    • Marked as answer by Plankt0n Tuesday, July 25, 2017 8:02 AM
    Tuesday, July 25, 2017 8:01 AM