470,815 Members | 1,340 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

Custom datagrid column

VC
Hi, could someone points me to a article, whitepaper or other about
how to create a simple custimized column for a (2008 .net)
DataGridView windows form control?

I've saw a lot of sample over the internet but all of them too much
complicated. I just need something simple since I'm a begginer in C#.

Thanks in advance.
Nov 7 '08 #1
3 3765
Not sure where an example would be online, but here's a technique that I use:

Create a DataTable with the columns you are interested in. Fill all of your
rows using the logic you created the columns with, then add the DataTable to
your DataGridView control.

EXAMPLE:
// Start Example Code:
DataTable table = new DataTable();
DataColumn col1 = table.Columns.Add("Col 1 Int32",
Type.GetType("System.Int32"));
DataColumn col2 = table.Columns.Add("Col 2 String",
Type.GetType("System.String"));
for (int i = 0; i < 5; i++) {
DataRow r = table.NewRow();
r[col1] = i;
r[col2] = string.Format("Data for {0}", i");
table.Rows.Add(r);
}
DataGridView1.DataSource = table.DefaultView;
// End of Example

If this isn't what you need, could you be a little more specific in your
question?

"VC" wrote:
Hi, could someone points me to a article, whitepaper or other about
how to create a simple custimized column for a (2008 .net)
DataGridView windows form control?

I've saw a lot of sample over the internet but all of them too much
complicated. I just need something simple since I'm a begginer in C#.

Thanks in advance.
Nov 7 '08 #2
VC
Hi

I 'd like to know how to create customized coluns on a DataGRidView.
In the past on VS2003, we were able to create coluns like
DataboundColunm, CheckBoxcolumn and so on. How do I create this kind
of columns in VC2008 datagridview now?

Or the unique way is creating customized columns on datatable and them
perform a dotabound?
On 7 nov, 20:26, jp2msft <jp2m...@discussions.microsoft.comwrote:
Not sure where an example would be online, but here's a technique that I use:

Create a DataTable with the columns you are interested in. Fill all of your
rows using the logic you created the columns with, then add the DataTableto
your DataGridView control.

EXAMPLE:
// Start Example Code:
DataTable table = new DataTable();
DataColumn col1 = table.Columns.Add("Col 1 Int32",
Type.GetType("System.Int32"));
DataColumn col2 = table.Columns.Add("Col 2 String",
Type.GetType("System.String"));
for (int i = 0; i < 5; i++) {
* DataRow r = table.NewRow();
* r[col1] = i;
* r[col2] = string.Format("Data for {0}", i");
* table.Rows.Add(r);}

DataGridView1.DataSource = table.DefaultView;
// End of Example

If this isn't what you need, could you be a little more specific in your
question?

"VC" wrote:
Hi, could someone points me to a article, whitepaper or other about
how to create a simple custimized column for a (2008 .net)
DataGridView windows form control?
I've saw a lot of sample over the internet but all of them too much
complicated. I just need something simple since I'm a begginer in C#.
Thanks in advance.
Nov 12 '08 #3
Could you post some example code of what you did and how you did it in VS2003?

If a DataColumn is specified as a Bit field (Boolean), CheckBoxes should
still show up whenever you include the DataTable containing the DataColumn to
your DataGridView.

"VC" wrote:
Hi

I 'd like to know how to create customized coluns on a DataGRidView.
In the past on VS2003, we were able to create coluns like
DataboundColunm, CheckBoxcolumn and so on. How do I create this kind
of columns in VC2008 datagridview now?

Or the unique way is creating customized columns on datatable and them
perform a dotabound?
On 7 nov, 20:26, jp2msft <jp2m...@discussions.microsoft.comwrote:
Not sure where an example would be online, but here's a technique that I use:

Create a DataTable with the columns you are interested in. Fill all of your
rows using the logic you created the columns with, then add the DataTable to
your DataGridView control.

EXAMPLE:
// Start Example Code:
DataTable table = new DataTable();
DataColumn col1 = table.Columns.Add("Col 1 Int32",
Type.GetType("System.Int32"));
DataColumn col2 = table.Columns.Add("Col 2 String",
Type.GetType("System.String"));
for (int i = 0; i < 5; i++) {
DataRow r = table.NewRow();
r[col1] = i;
r[col2] = string.Format("Data for {0}", i");
table.Rows.Add(r);}

DataGridView1.DataSource = table.DefaultView;
// End of Example

If this isn't what you need, could you be a little more specific in your
question?

"VC" wrote:
Hi, could someone points me to a article, whitepaper or other about
how to create a simple custimized column for a (2008 .net)
DataGridView windows form control?
I've saw a lot of sample over the internet but all of them too much
complicated. I just need something simple since I'm a begginer in C#.
Thanks in advance.

Nov 13 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Conawapa11 | last post: by
7 posts views Thread by Girish | last post: by
4 posts views Thread by Steve | last post: by
6 posts views Thread by Bob The Builder | last post: by
reply views Thread by simchajoy2000 | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.