Solved

Copy & Past in VB 2012 texboxes

Posted on 2013-05-22
8
327 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 86

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 86

Expert Comment

by:Mike Tomlinson
ID: 39188654
You must have set ShortcutsEnabled() for your TextBoxes to False.
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

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

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 86

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

717 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