Solved

Copy & Past in VB 2012 texboxes

Posted on 2013-05-22
8
325 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get the selected ValueMember of Combobox 5 38
SSRS troubles 4 68
SqlServer no dupes 25 37
Toolbar to format all windows forms controls at design time needed 5 13
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

790 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