Avatar of jampost
jampost
Flag for United States of America asked on

Copy & Past in VB 2012 texboxes

At run time, I want the user to be able to copy from one text box and past to another textbox in a visual basic 2012 application. The textboxes really have nothing programmable going on with them. They (Textbox1 through Textbox12) are on a windows form for the purpose of being able to type info in them and printing the form out using "printform" from VB power pack. I am looking for code that will hopefully handle all 12 text boxes on this form. Thank you for any help.
Visual Basic.NETMicrosoft Development

Avatar of undefined
Last Comment
Mike Tomlinson

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mike Tomlinson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jampost

ASKER
Idle Mind,

   I was thinking that too. So I need to find out why "at run time" I can not simply Ctrl-C in one Textbox and Ctrl-V to another textbox copying the contents from one to another. I'll look into prperties to see if something is turned off or on that shouldn't be.
Mike Tomlinson

You must have set ShortcutsEnabled() for your TextBoxes to False.
jampost

ASKER
I checked ShortcutsEnabled() for your TextBoxes. they are all "true"
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Mike Tomlinson

Can you give more details about your app and setup?...
jampost

ASKER
Idle Mind,

Here is the code behind the form.



Public Class Orders

    Private m_path As String = "C:\Users\Joe\Documents\Visual Studio 2012\Projects\sa_Shipping-Receiving\My Project\Images\VL"




    Private Sub Orders_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadPictures()

    End Sub

    Private Sub LoadPictures()

        Dim dir As New IO.DirectoryInfo(m_path)


        'Dim files As IO.FileInfo() = dir.GetFiles("*.jpeg")

        Dim files As IO.FileInfo() = dir.GetFiles.Where(Function(fi) fi.Extension.ToLower = ".jpeg" OrElse fi.Extension.ToLower = ".png" OrElse fi.Extension.ToLower = ".jpg" OrElse fi.Extension.ToLower = ".gif").ToArray

        Dim dra As IO.FileInfo
        For Each dra In files
            ComboBox1.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox2.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox3.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox4.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox5.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox6.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox7.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox8.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox9.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox10.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox11.Items.Add(dra.Name)
        Next
        For Each dra In files
            ComboBox12.Items.Add(dra.Name)
        Next  

       

    End Sub


    Private Sub Main_Click(sender As Object, e As EventArgs) Handles Main.Click
        Dim main As New Main
        main.Show()
        Me.Hide()

    End Sub

    Private Sub MnuExit_Click(sender As Object, e As EventArgs) Handles MnuExit.Click
        Me.Close()
        End
    End Sub


    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged

        If Not (ComboBox1.SelectedItem Is Nothing) Then
            Me.PictureBox1.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox1.SelectedItem.ToString))
        End If
        Label1.Text = ComboBox1.SelectedItem.ToString
    End Sub



    Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
        If Not (ComboBox2.SelectedItem Is Nothing) Then
            Me.PictureBox2.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox2.SelectedItem.ToString))
        End If
        Label2.Text = ComboBox2.SelectedItem.ToString
    End Sub

    Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged
        If Not (ComboBox3.SelectedItem Is Nothing) Then
            Me.PictureBox3.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox3.SelectedItem.ToString))
        End If
        Label3.Text = ComboBox3.SelectedItem.ToString
    End Sub

    Private Sub ComboBox4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox4.SelectedIndexChanged
        If Not (ComboBox4.SelectedItem Is Nothing) Then
            Me.PictureBox4.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox4.SelectedItem.ToString))
        End If
        Label4.Text = ComboBox4.SelectedItem.ToString
    End Sub

    Private Sub ComboBox5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox5.SelectedIndexChanged
        If Not (ComboBox5.SelectedItem Is Nothing) Then
            Me.PictureBox5.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox5.SelectedItem.ToString))
        End If
        Label5.Text = ComboBox5.SelectedItem.ToString
    End Sub

    Private Sub ComboBox6_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox6.SelectedIndexChanged
        If Not (ComboBox6.SelectedItem Is Nothing) Then
            Me.PictureBox6.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox6.SelectedItem.ToString))
        End If
        Label6.Text = ComboBox6.SelectedItem.ToString
    End Sub


    Private Sub ComboBox10_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox10.SelectedIndexChanged
        If Not (ComboBox10.SelectedItem Is Nothing) Then
            Me.PictureBox10.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox10.SelectedItem.ToString))
        End If
        Label10.Text = ComboBox10.SelectedItem.ToString
    End Sub


    Private Sub ComboBox11_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox11.SelectedIndexChanged
        If Not (ComboBox11.SelectedItem Is Nothing) Then
            Me.PictureBox11.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox11.SelectedItem.ToString))
        End If
        Label11.Text = ComboBox11.SelectedItem.ToString
    End Sub

    Private Sub ComboBox12_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox12.SelectedIndexChanged
        If Not (ComboBox12.SelectedItem Is Nothing) Then
            Me.PictureBox12.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox12.SelectedItem.ToString))
        End If
        Label12.Text = ComboBox12.SelectedItem.ToString
    End Sub

   

   

    Private Sub MnuPrint_Click(sender As Object, e As EventArgs) Handles MnuPrint.Click

        'try this:
        Me.PrintForm1.PrinterSettings.DefaultPageSettings.Landscape = False
        Me.PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Top = 25
        Me.PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Left = 50
        Me.PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Right = 0 '0.5
        Me.PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Bottom = 0 '0.5
        '~~~~~~~~~~~~~~~~~~~~~~


        Me.PrintForm1.PrintAction = System.Drawing.Printing.PrintAction.PrintToPreview
        Me.PrintForm1.Print()

    End Sub

 

    Private Sub ComboBox7_SelectedIndexChanged_1(sender As Object, e As EventArgs) Handles ComboBox7.SelectedIndexChanged
        If Not (ComboBox7.SelectedItem Is Nothing) Then
            Me.PictureBox7.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox7.SelectedItem.ToString))
        End If
        Label7.Text = ComboBox7.SelectedItem.ToString
    End Sub

    Private Sub ComboBox8_SelectedIndexChanged_1(sender As Object, e As EventArgs) Handles ComboBox8.SelectedIndexChanged
        If Not (ComboBox8.SelectedItem Is Nothing) Then
            Me.PictureBox8.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox8.SelectedItem.ToString))
        End If
        Label8.Text = ComboBox8.SelectedItem.ToString
    End Sub

    Private Sub ComboBox9_SelectedIndexChanged_1(sender As Object, e As EventArgs) Handles ComboBox9.SelectedIndexChanged
        If Not (ComboBox9.SelectedItem Is Nothing) Then
            Me.PictureBox9.Image = Image.FromFile(IO.Path.Combine(m_path, ComboBox9.SelectedItem.ToString))
        End If
        Label9.Text = ComboBox9.SelectedItem.ToString
    End Sub

    Private Sub MnuRefresh_Click(sender As Object, e As EventArgs) Handles MnuRefresh.Click

        Dim main As New Main
        main.Show()
        Me.Hide()
        Dim Orders As New Orders
        Orders.Show()
        main.Hide()

    End Sub

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged

    End Sub

    Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged

    End Sub

    Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged

    End Sub
End Class
jampost

ASKER
Idle Mind,

  I attached a design view "screenPrint"
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Mike Tomlinson

Did you figure it out?  I didn't have time to look at your code yet...