473,493 Members | 3,174 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Adding columns to datagrid whose datasource is datatable

The Winform datagrid I'm working is already displaying data from a
datatable. How can I add columns to that datagrid? I know (or at least I
think I know) how to add the tableStyle and gridColumnStyles during design
time but I don't know what to do next (make the grid display the data). The
datatable is filled during run-time.

Thanks,
Angel
Nov 16 '05 #1
2 4841
Never mind. I figured it out.

DataGridTableStyle ts_auditAddress = new DataGridTableStyle(); //Creates
new table Style

ts_auditAddress.MappingName = "AZMViewTable"; //Maps tablestyle to grid
datasource
DataGridTextBoxColumn DataCol_key = new DataGridTextBoxColumn(); //Adds
column to tableStyle
DataCol_key.HeaderText = "Customer Key";
DataCol_key.MappingName = "col_Key"; //maps Columnstyle DataCol_key to
column in datatable named col_Key.
ts_auditAddress.GridColumnStyles.Add(DataCol_key); //Adds Columnstyle
DataCol_key to TableStyle

dataGrid_auditAddress.TableStyles.Add(ts_auditAddr ess);

Thanks,
Angel

"Angel" <none> wrote in message news:Or*************@TK2MSFTNGP12.phx.gbl...
The Winform datagrid I'm working is already displaying data from a
datatable. How can I add columns to that datagrid? I know (or at least I
think I know) how to add the tableStyle and gridColumnStyles during design
time but I don't know what to do next (make the grid display the data). The datatable is filled during run-time.

Thanks,
Angel

Nov 16 '05 #2
Add a DataGridTableStyle and then DataGridColumnStyle 's for the new
columns. Just set the MappingName to the name of the new column.
"Angel" <none> wrote in message news:Or*************@TK2MSFTNGP12.phx.gbl...
The Winform datagrid I'm working is already displaying data from a
datatable. How can I add columns to that datagrid? I know (or at least I
think I know) how to add the tableStyle and gridColumnStyles during design
time but I don't know what to do next (make the grid display the data). The datatable is filled during run-time.

Thanks,
Angel

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
4600
by: DraguVaso | last post by:
Hi, I need a function that gives me the number of Columns shown in a DataGrid. So I don't need to know the number of columns shown in tha DataSource, because this number can be completely...
0
3110
by: Dave Elliott | last post by:
After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is after the newly added row without getting bizarre results. I have added the...
3
1744
by: Alexander | last post by:
Hi, I am using a DataGrid and assign a DataTable as a DataSource to it: void ShowData() { DataTable myNewDataTable = new DataTable(); ... // fill table this.m_DataGrid1.DataSource =...
6
3216
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order...
3
4854
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
1
3257
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
2
6371
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
2
3538
by: Flack | last post by:
Hey guys, I have a DataGrid and DataTable field in my class : private ImageDataGrid dataGrid1; //ImageDataGrid extends dataGrid and just overides OnMouseDown private DataTable dt = new...
3
1175
by: triumph | last post by:
Hi, I'm using datagrid where i have some fields generated from sql. I have to include some other fields which have been set as default columns given below. Dim dttad As New DataTable Dim dr...
0
7119
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
7157
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
7195
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
5453
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,...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.