8 Replies - 423 Views - Last Post: 14 January 2013 - 12:45 PM Rate Topic: -----

#1 Knowledge needed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 07-January 13

VS 2012 - Object

Posted 13 January 2013 - 12:45 AM

Is there a way to make a object(text box;..) with a button (new object for the user on MY project)?
Is This A Good Question/Topic? 0
  • +

Replies To: VS 2012 - Object

#2 B7vks  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 02-July 12

Re: VS 2012 - Object

Posted 13 January 2013 - 01:49 AM

from tool box
Was This Post Helpful? 0
  • +
  • -

#3 Knowledge needed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 07-January 13

Re: VS 2012 - Object

Posted 13 January 2013 - 03:32 AM

:D - Uhm I want to make a program that makes text boxes meaning when the click on a button in my created project that it creates a text box or ...(what ever in the toolbox) instead of creating allot of them and hiding them until needed.

For example : A program where you can create your own form - that's my objective of my program and this point.

Thanks
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3745
  • View blog
  • Posts: 13,114
  • Joined: 12-December 12

Re: VS 2012 - Object

Posted 13 January 2013 - 04:52 AM

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim tb As TextBox

        tb = New TextBox
        tb.Text = "Hi new textbox"
        tb.Name = "txtNew1"

        tb.Location = New Point(10, 10)
        Me.Controls.Add(tb)
    End Sub

Was This Post Helpful? 0
  • +
  • -

#5 Knowledge needed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 07-January 13

Re: VS 2012 - Object

Posted 14 January 2013 - 05:52 AM

D.I.C Regular!!! Thanks allot :D

Is there anyway that you can save it to the project.. when it loads up again the text box still exist?

Please and thank you :D

Rudi
Was This Post Helpful? 0
  • +
  • -

#6 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: VS 2012 - Object

Posted 14 January 2013 - 06:06 AM

Quote

Is there anyway that you can save it to the project.. when it loads up again the text box still exist?

Yes. When you create the TextBox, save all the properties you care about in My.Settings, or in a file.

When you run the program, use that data to to configure a New TextBox.
Was This Post Helpful? 0
  • +
  • -

#7 Knowledge needed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 07-January 13

Re: VS 2012 - Object

Posted 14 January 2013 - 06:08 AM

 My.Settings.Save(tb) 


Error.. how sould i save it?
Was This Post Helpful? 0
  • +
  • -

#8 Knowledge needed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 07-January 13

Re: VS 2012 - Object

Posted 14 January 2013 - 06:16 AM

 My.Settings.TB.Contains(tb.Name) 
TB = string/user?
 Dim c As New TextBox 
c.Name = My.Settings.TB

-> load form
Was This Post Helpful? 0
  • +
  • -

#9 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: VS 2012 - Object

Posted 14 January 2013 - 12:45 PM

Adding on to what andrewsw said, here is a small program to generate a TextBox, save some properties in My.settings, and to recreate it when the form loads. It changes the Text, so you can see that it recreated it from My.Settings.

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim tb As TextBox
        tb = New TextBox
        tb.Text = "Hi new textbox"
        tb.Name = "txtNew1"
        tb.Location = New Point(10, 20)
        Me.Controls.Add(tb)
        My.Settings.tbName = tb.Name
        My.Settings.tbX = 10
        My.Settings.tbY = 20
        My.Settings.tbText = "This text was saved"
    End Sub

    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If My.Settings.tbName <> "" Then
            Dim tb As TextBox
            tb = New TextBox
            tb.Name = My.Settings.tbName
            tb.Location = New Point(My.Settings.tbX, My.Settings.tbY)
            tb.Text = My.Settings.tbText
            Me.Controls.Add(tb)
        End If
    End Sub


All that being said, and depending on how many controls you want to add/reload, you might be better off with a file (XML is best).
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1