Solved

Copy & Past in VB 2012 texboxes

Posted on 2013-05-22
8
324 Views
Last Modified: 2013-05-22
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.
0
Comment
Question by:jampost
  • 4
  • 4
8 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 39188587
They already do this out of the box...
0
 

Author Comment

by:jampost
ID: 39188620
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.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 39188654
You must have set ShortcutsEnabled() for your TextBoxes to False.
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:jampost
ID: 39188663
I checked ShortcutsEnabled() for your TextBoxes. they are all "true"
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 39188671
Can you give more details about your app and setup?...
0
 

Author Comment

by:jampost
ID: 39188729
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
0
 

Author Comment

by:jampost
ID: 39188804
Idle Mind,

  I attached a design view "screenPrint"
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 39189714
Did you figure it out?  I didn't have time to look at your code yet...
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
start a process from a service 3 23
"Video DataSource is Offline or not responding"  - why? 1 34
vb.net 1 month apart 11 31
vb.net winforms sizing/resolution? 4 34
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question