|
-
Feb 3rd, 2008, 10:33 PM
#1
Thread Starter
Fanatic Member
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.
-
Feb 3rd, 2008, 11:21 PM
#2
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.
-
Feb 4th, 2008, 02:39 AM
#3
Fanatic Member
Re: datagridview
or Add Your Nick Columns To DataGridView manually & then Fill it using DataReader
-
Feb 4th, 2008, 04:19 AM
#4
Thread Starter
Fanatic Member
Re: datagridview
 Originally Posted by killer7k
or Add Your Nick Columns To DataGridView manually & then Fill it using DataReader
what is a "Nick" column???
-
Feb 4th, 2008, 06:34 AM
#5
Thread Starter
Fanatic Member
Re: datagridview
 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??
-
Feb 4th, 2008, 07:27 AM
#6
Re: datagridview
 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.
-
Feb 4th, 2008, 07:29 AM
#7
Thread Starter
Fanatic Member
Re: datagridview
 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.
-
Feb 4th, 2008, 08:00 AM
#8
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.
-
Feb 4th, 2008, 10:53 AM
#9
Thread Starter
Fanatic Member
Re: datagridview
 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.
-
Feb 4th, 2008, 02:41 PM
#10
Fanatic Member
Re: datagridview
 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
-
Feb 4th, 2008, 04:35 PM
#11
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|