Results 1 to 11 of 11

Thread: datagridview

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Location
    ohio, usa
    Posts
    719

    datagridview

    I have my program running and i have ran a query with sql to get the records required.(access .mdb) I can load them all in the old flexgrid with no problem.


    can I bring up the datagridview to show the current records and showing only the fields I want and naming the fields as I desire(not using the field names in the db)??


    I just want to use the datagridview in place of the old flexgrid.


    can the datagridview be used in this manner?

    I have a demo but all of it was setup using the ide, there was no code used to set it up.
    Last edited by RonR; Feb 3rd, 2008 at 10:37 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: datagridview

    The DataGridView is eminently customisable. If you want to use it and you want to know how to use it then you really should have gone first to the documentation, as usual. MSDN has tons of information on the DataGridView, broken up into numerous specific topics.

    http://msdn2.microsoft.com/en-us/lib...8VS.80%29.aspx

    Now, with regards to what and how columns get shown, you have basically three options:

    1. Bind your data to the grid via its DataSource property and let it create the columns for you. This is the better option if you want to accept the default configuration for each column or you just want to make a few minor changes.

    2. Add the columns to the grid in the designer and customise them as required just like any other design-time component. You set the DataPropertyName to force a grid column to bind to a data source column or property when the grid is bound. You need to set the AutoGenerateColumns property to False, which must be done in code before setting the DataSource property.

    3. Use a combination of 1 and 2. You can add one or more columns in the designer and then let the grid automatically generate the columns for the remaining columns or properties of the data source. In this case you leave AutoGenerateColumn as the default True value. An example of where this would be suitable is if you want one column to display ComboBoxes instead of TextBoxes but you want all the other columns to display with the default style.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: datagridview

    or Add Your Nick Columns To DataGridView manually & then Fill it using DataReader

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Location
    ohio, usa
    Posts
    719

    Re: datagridview

    Quote Originally Posted by killer7k
    or Add Your Nick Columns To DataGridView manually & then Fill it using DataReader

    what is a "Nick" column???

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Location
    ohio, usa
    Posts
    719

    Re: datagridview

    Quote Originally Posted by RonR
    what is a "Nick" column???

    Do you mean that you can fill the datagridview using DataReader rather than binding the db to the datagridview??


    either way could you give me a little more detail??

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: datagridview

    Quote Originally Posted by RonR
    Do you mean that you can fill the datagridview using DataReader rather than binding the db to the datagridview??
    Why would you want to? That's way more work.

    Have you done this yet?
    Add the columns to the grid in the designer and customise them as required just like any other design-time component. You set the DataPropertyName to force a grid column to bind to a data source column or property when the grid is bound. You need to set the AutoGenerateColumns property to False, which must be done in code before setting the DataSource property.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Location
    ohio, usa
    Posts
    719

    Re: datagridview

    Quote Originally Posted by jmcilhinney
    Why would you want to? That's way more work.

    Have you done this yet?

    I am just trying to find out as much as I can before I go any farther.

    I need the datagridview and I need it to do everything required to get my project to work the way it needs to work and if it requires a ton of code then that is just the way it is but I do want to do more research before jumping into anything.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: datagridview

    Nothing you've asked for in this thread would make a DataGridView break a sweat. Columns and rows are both customisable and you can embed absolutely any control you like in a cell, with varying degrees of effort depending on the control. Like I said, if you really want to know about the DataGridView class then you should be reading about it on MSDN. That's where you'll find out about its capabilities.

    The one disappointing omission in the DataGridView that I'm aware of is that it doesn't support parent and child data in the one control. There's no expandability like the Access UI and there's no navigation from table to table like the DataGrid. Other than that it's way cool.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Location
    ohio, usa
    Posts
    719

    Re: datagridview

    Quote Originally Posted by jmcilhinney
    Nothing you've asked for in this thread would make a DataGridView break a sweat. Columns and rows are both customisable and you can embed absolutely any control you like in a cell, with varying degrees of effort depending on the control. Like I said, if you really want to know about the DataGridView class then you should be reading about it on MSDN. That's where you'll find out about its capabilities.

    The one disappointing omission in the DataGridView that I'm aware of is that it doesn't support parent and child data in the one control. There's no expandability like the Access UI and there's no navigation from table to table like the DataGrid. Other than that it's way cool.

    ok and thanks.

  10. #10
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: datagridview

    Quote Originally Posted by RonR
    Do you mean that you can fill the datagridview using DataReader rather than binding the db to the datagridview??


    either way could you give me a little more detail??
    Yes , You can Name Your DataGridView Column With Your Choice
    DataGridView1.columns.add("..","..")
    & Then You Can use The DataReader To Read The Query & Then You fill Your DataGridView !
    As John Sais You Have 2 Things
    Using DataSet or DataReader
    .......Yes maybe easy with DataSet but Good To Know Others also

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Location
    ohio, usa
    Posts
    719

    Re: datagridview

    yes, it is good to know all the options.

    thanks!!!

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