Results 1 to 7 of 7

Thread: datagrid help

  1. #1

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    datagrid help

    can someone please help me... I will be completely honest here... I have no freaking cute how to really use the datagrid and none of my books have been any help... is there any way to retreive data using inner joins and then place the information into the datagrid and format the header text and the columns themselves so that if it's null to just clear it and to have it readonly... here's me code along with a screen shot of what i still come up with... i'm pulling what hair that i have left out here.... please i'm on my knee help!!!

    the code is just for testing until i figure this out.
    VB Code:
    1. Private Sub InitialDataGrid()
    2.         Dim ds As New DataSet
    3.  
    4.         Dim sql As New StringBuilder
    5.         With sql
    6.             .Append("SELECT library_tbl.library_name, library_tbl.address1, ")
    7.             .Append("library_tbl.address2, location_tbl.city, location_tbl.state, ")
    8.             .Append("location_tbl.ZIPCODE, library_tbl.phone, library_tbl.fax ")
    9.             .Append("FROM location_tbl INNER JOIN library_tbl ON ")
    10.             .Append("location_tbl.ZIPCODE = library_tbl.LOCATION_ID")
    11.         End With
    12.         Dim daLibs As New OleDb.OleDbDataAdapter(sql.ToString, cn)
    13.  
    14.         daLibs.Fill(ds)
    15.         Me.DataGrid1.DataSource = ds
    16.         Dim dgtsInfo As New DataGridTableStyle
    17.         With dgtsInfo
    18.             .MappingName = "library_tbl"
    19.  
    20.             Dim dgtbcCity As New DataGridTextBoxColumn
    21.             With dgtbcCity
    22.                 .HeaderText = "City"
    23.                 .MappingName = "loction_tbl.city"
    24.                 .NullText = ""
    25.                 .ReadOnly = True
    26.             End With
    27.  
    28.             .GridColumnStyles.Add(dgtbcCity)
    29.         End With
    30.  
    31.         Me.DataGrid1.TableStyles.Add(dgtsInfo)
    32.  
    33.     End Sub

    screen shot of what i actually get

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: datagrid help

    you should consider using a listview.... they are just so much nicer than the datagrid, especially since I see you are using it as a readonly data display...

    i know sometimes people don't want someone suggesting them in the other direction and would rather fix the issue at hand...

    I personally don't know how you can mask data in the datagrid, because I never use it, but I imagine there has to be a way, if there isn't you could always put that in your SQL Statement, with a select case or something along those lines

    but have you used the listview in any of your other apps?

  3. #3

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: datagrid help

    i was affraid you were going to suggest the listview... yes i've used it before... the only reason i didn't want to use it here was because of the time it takes to load the data into the view... unless you know of a quicker way to load the data i will still have to loop through the records to load them... oh well... you would think that they would have made the datagrid so that you could have manipulated the data a little easier... but then again that's M$ for you. thanx kleinma

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: datagrid help

    I have an app that I moved from VB6 to VB.NET

    this app loads records (with about 12 fields) into a listview...

    the code to load the listview in VB6 took upwards of 20 seconds to load the list, the same code written in .net loads in about 5

    I think its a combination of the listview and database access code both improved in .net

    but anyways i think i got it for you
    VB Code:
    1. Dim dgtbcCity As New DataGridTextBoxColumn
    2.             With dgtbcCity
    3.                 [b].NullText = "NO DATA"[/b]
    4.                 .HeaderText = "City"
    5.                 .MappingName = "loction_tbl.city"
    6.                 .NullText = ""
    7.                 .ReadOnly = True
    8.             End With

  5. #5

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: datagrid help

    Quote Originally Posted by kleinma
    I have an app that I moved from VB6 to VB.NET

    this app loads records (with about 12 fields) into a listview...

    the code to load the listview in VB6 took upwards of 20 seconds to load the list, the same code written in .net loads in about 5

    I think its a combination of the listview and database access code both improved in .net

    but anyways i think i got it for you
    VB Code:
    1. Dim dgtbcCity As New DataGridTextBoxColumn
    2.             With dgtbcCity
    3.                 [b].NullText = "NO DATA"[/b]
    4.                 .HeaderText = "City"
    5.                 .MappingName = "loction_tbl.city"
    6.                 .NullText = ""
    7.                 .ReadOnly = True
    8.             End With

    sorry kleinma i guess i didn't explain it very well.. yea i know how to set if it's null data with the NullText... my problem is when it loads with the inner joins i can use, or should i say i don't know how to use, the mapping correctly to get the information to show up correctly... i also don't want to have the little + signs indicating the relationship between the tables... i woud like it to look like that of any datatable that is pulled up in something like access MySQL or SQL server... if i do an inner join and i want to see library name in the library table and the city it where the library is located, and the city is in a different table i want to use the inner join to get the information from both tables and display it in one line in the view.... i hope this makes a little better sense. sorry for the confusion.

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: datagrid help

    not sure if i can help you there then... try the listview.. and see if it really is that slow... maybe it wont be so bad

  7. #7

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: datagrid help

    yea that's the route i'm going to go. thanx again.

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

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