Results 1 to 10 of 10

Thread: Continuous Display or Data From DataTable

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2014
    Posts
    122

    Continuous Display or Data From DataTable

    Hi,

    I could do with some help pointers on this.

    Using a for each on a data table which contains notes for the parent record, I would like to build a continuous display up.

    I could use a grid but thats not really suitable.

    I am currently using a Tab Control and this information will be under its own tab - chose to use this as it is scrollable

    I need to display it in following fashion or similar

    Name:  example.JPG
Views: 172
Size:  10.3 KB

    Lable = name of person

    TextBox = Note

    Buttons, Delete & Add New etc

    and then adds same set of controls for each record below at runtime

    help apprecated

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,753

    Re: Continuous Display or Data From DataTable

    I have a few questions for you:
    1. How will you know which name and note to display when the form loads?
    2. Are you populating the data into a DataTable from a database?
    3. Are you just not comfortable with SQL commands or do you not know how to use them?
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2014
    Posts
    122

    Re: Continuous Display or Data From DataTable

    Quote Originally Posted by dday9 View Post
    I have a few questions for you:
    1. How will you know which name and note to display when the form loads?
    2. Are you populating the data into a DataTable from a database?
    3. Are you just not comfortable with SQL commands or do you not know how to use them?

    Hi,



    Should have said I'm using VB 2010 Windows Form

    I am using table adapters:

    I have no issues getting the data into the adapters using SQL I just wont to know if can do a kinda continous form to display the data.

    ie as a DGV is not really suitable, I would like to add the controls, kinda like how a forum works.

    i.e

    Show note 1 details

    --------------------

    Show note 2 details

    etc

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,753

    Re: Continuous Display or Data From DataTable

    OK, so I created a simple database. It contains 1 data table named Details and 3 columns:
    1. ID - Primary Key - Auto-Generated Number
    2. PersonName - Short Text
    3. Note - Long Text


    In the Data Sources window(shift+alt+d), I expanded the Details table, changed the Details table to show details rather than the DataGridView, changed the PersonName column to Label, and then drag/dropped the Details table onto the Form.

    From there I deleted the following controls:
    • The label that shows "ID" for the ID column
    • The TextBox that gets/sets value for the ID column
    • The label that shows "Person Name" for the PersonName column
    • The label that shows "Note" for the Note column


    I then docked the Label that gets the value for the PersonName column to Top and changed the AutoSize property to True. Next I docked the TextBox that gets/sets the value for the Note column to Fill and changed the Multiline property to True. I also had to right-click the TextBox and click on "bring to front" in order for the docking to act the way I wanted it to.

    Not only does this give me the control layout that you want, but it also give me the BindingNavigator with add/delete/save buttons.
    Last edited by dday9; Nov 23rd, 2016 at 10:59 AM. Reason: bring to front, not send to back
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  5. #5
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: Continuous Display or Data From DataTable

    From the your description in post #1, it sounds like you want the functionality of the Visual Basic Power Packs DataRepeater Control

    VisualBasic PowerPack missing from Visual Studio 2013?

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Apr 2014
    Posts
    122

    Re: Continuous Display or Data From DataTable

    Quote Originally Posted by TnTinMN View Post
    From the your description in post #1, it sounds like you want the functionality of the Visual Basic Power Packs DataRepeater Control

    VisualBasic PowerPack missing from Visual Studio 2013?
    Yes this is exactly what I was looking for.

    dday9 thank you showing how I change layout of datasource before dragging

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Apr 2014
    Posts
    122

    Re: Continuous Display or Data From DataTable

    Next daft question

    If I put on a button in the DataRepeater from the click event on the button how would I get the reference to the row I was on so I could then reference the data in textboxes etc.

  8. #8
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: Continuous Display or Data From DataTable

    Quote Originally Posted by jpskiller View Post
    Next daft question

    If I put on a button in the DataRepeater from the click event on the button how would I get the reference to the row I was on so I could then reference the data in textboxes etc.
    I'll answer with more questions. Have you considered reading the documentation for the DataRepeater? If not, why not?

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Apr 2014
    Posts
    122

    Re: Continuous Display or Data From DataTable

    Thanks got it working now

    I dragged my Datasource on to the DataRepeater and that works fine, so I added a button and in the button On Click Event I added

    Code:
      Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Dim Product As String = DataRepeater1.CurrentItem.Controls("ProductNameTextBox").Text
    
            MessageBox.Show(Product)
    
        End Sub

  10. #10
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: Continuous Display or Data From DataTable

    Quote Originally Posted by jpskiller View Post
    Thanks got it working now
    Glad to know that you worked it out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width