8 Replies - 171 Views - Last Post: 27 December 2018 - 08:30 PM Rate Topic: -----

#1 Rabastan   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 134
  • Joined: 27-August 12

Add new Textbox for each row in Datatable

Posted 27 December 2018 - 02:44 PM

While in the process of learning I had to step away to take care of my mom when she got sick. It seems I have forgotten quite a bit. But, I think I am close. I have my Database, Query is working. I need to Create a new textbox in the panet for each row in the DataTable. All my database commands are held in a separate class I know the Query is working because I tested it in a Datagrid.

Here is what I have

Private DBc As New DBControl

Private DBc As New DBControl

Private Sub HeaderPanel_Paint(sender As Object, e As PaintEventArgs) Handles HeaderPanel.Paint
        'Query Header for header list
        DBc.ExecQuery("SELECT HeaderNameEng FROM MenuHeaders")
        If Not String.IsNullOrEmpty(DBc.Exception) Then MsgBox(DBc.Exception)

        Dim tb As New TextBox
        For Each R As DataRow In DBc.DBDT.Rows
            tb.Add(R)
        Next
    End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: Add new Textbox for each row in Datatable

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14691
  • View blog
  • Posts: 58,718
  • Joined: 12-June 08

Re: Add new Textbox for each row in Datatable

Posted 27 December 2018 - 04:25 PM

Pause for a moment.. why do you need to dynamically create 0 to N textbox GUI objects? What's the purpose?
Was This Post Helpful? 0
  • +
  • -

#3 Rabastan   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 134
  • Joined: 27-August 12

Re: Add new Textbox for each row in Datatable

Posted 27 December 2018 - 04:40 PM

The program is for my sisters restaurant. The Idea is to have menu items, their description and price go in to a column from the database so she can drag and drop them on to the menu.

As I am sure this may not be the "BEst way of doing it" as I said, I am Learning / Re Learning, So if there is a better way I am all ears

This post has been edited by Rabastan: 27 December 2018 - 04:39 PM

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14691
  • View blog
  • Posts: 58,718
  • Joined: 12-June 08

Re: Add new Textbox for each row in Datatable

Posted 27 December 2018 - 04:42 PM

For what ever reason that is not making sense. One would figure there is a static amount of space to.. I guess show things on a monitor?.. You would fill them as needed from being pulled out of the db.
Was This Post Helpful? 0
  • +
  • -

#5 Rabastan   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 134
  • Joined: 27-August 12

Re: Add new Textbox for each row in Datatable

Posted 27 December 2018 - 04:59 PM

The reason i want it to be dynamic is menu items are dynamic, and there may be a different amount at any time.
Was This Post Helpful? 0
  • +
  • -

#6 Rabastan   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 134
  • Joined: 27-August 12

Re: Add new Textbox for each row in Datatable

Posted 27 December 2018 - 05:08 PM

Would it be a better Idea to get a record count then add the text boxes based on the record count?
Was This Post Helpful? 0
  • +
  • -

#7 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 171
  • View blog
  • Posts: 1,025
  • Joined: 05-December 13

Re: Add new Textbox for each row in Datatable

Posted 27 December 2018 - 05:22 PM

How many textboes are we talking about creating here?

This sounds horrible, to be honest, and I think you should look at a different approach.
Was This Post Helpful? 0
  • +
  • -

#8 Rabastan   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 134
  • Joined: 27-August 12

Re: Add new Textbox for each row in Datatable

Posted 27 December 2018 - 05:31 PM

20 Tops
Was This Post Helpful? 0
  • +
  • -

#9 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 171
  • View blog
  • Posts: 1,025
  • Joined: 05-December 13

Re: Add new Textbox for each row in Datatable

Posted 27 December 2018 - 08:30 PM

I am not sure why you'd want to use 20 textboxes. And there are obviously better ways to do it using other controls. I'd look at other controls. Like a listview or listboxes or even a treeview, which would be more practical than banging a load of textboxes out dynamically and pragmatically.

If I have more time tomorrow, I will try conjure up something for you to get you started. Something more useful than my "This sounds horrible" reply. Meanwhile look into using another control, or rethink your business logic. 20 Tb controls is not very practical. Once you've decided, let us know which way you want to go with it?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1