473,467 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 3872
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: The_Rave | last post by:
Hi everyone, I'm trying to add my own template columns to the property builder of ..NET. E.g. a checkbox column, or an image column. But I can't find the sources of the wizard, or a way to add...
0
by: Lenny | last post by:
Hello, I have an html table template which I want to turn into ASP.NET custom control. I want to utilize the best features of OOP. I want to be able to create columns headings dynamically, add...
1
by: Conawapa11 | last post by:
I'm having trouble figuring this problem out and every example out there deals with simple objects within a custom collection. Take this example: public class ComplexClass { private int id;...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
7
by: Girish | last post by:
OK.. phew. Playing with data grids for the past few days has been fun and a huge learning experience.. My problem. I have a requirement to display a gird with a gird. Within the embedded grid,...
4
by: Steve | last post by:
I am fairly new to VB.NET, and I am rewriting an application I wrote a while back, also in VB.NET. I aplied some new things I learned. Anyway, here is my problem....... I have a custom DataGrid...
1
by: nate axtell | last post by:
In VB .Net I made a custom CheckBox column style (for the Datagrid control) that maps to two DataTable columns , one it uses for the Checked status and the other it uses for the Enabled status. I am...
6
by: Bob The Builder | last post by:
I have a custom-built datagrid for windows forms. I overrode the scrollbars in it because I wanted to draw my own (basically, they're skinned). As a result, I handle all scroll events and calls. ...
2
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just...
0
by: simchajoy2000 | last post by:
Hi, I am trying to design a custom datagrid column that will allow me to put a combobox of colors in it. Well actually I can get that far but I can't figure out a way to save the color in the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.