•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 423,505 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,629 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 3748 | Replies: 6
![]() |
•
•
Join Date: Jul 2007
Posts: 17
Reputation:
Rep Power: 2
Solved Threads: 0
Hi 
I want to move the data in a cartein
table to a DataGrid.
What im doing right now is using the:
dataGridView1.DataSource = dataset.Tables[0];
And its adding rows and columns automaticly according to the data base.
(including the headers)
I dont want to do it like that,
i want to design manualy the DataGrid at the beginning.
and then just put the data inside my designed
datagrid, without changing anything or add anything, and without the Headers.
(i want to make my own headers)
How can i do that ?
[im using visual c# with Pervasive.SQL 8]
Thanks.

I want to move the data in a cartein
table to a DataGrid.
What im doing right now is using the:
dataGridView1.DataSource = dataset.Tables[0];
And its adding rows and columns automaticly according to the data base.
(including the headers)
I dont want to do it like that,
i want to design manualy the DataGrid at the beginning.
and then just put the data inside my designed
datagrid, without changing anything or add anything, and without the Headers.
(i want to make my own headers)
How can i do that ?
[im using visual c# with Pervasive.SQL 8]
Thanks.
This is a DataGrid and not a DataGridView, right? DataGrids are weird in that you have to make a table style to the grid and add columns to the table style to get what you want. DataGrids aren't a storage medium, they're a presentation tool so you can't store rows in the grid itself. What you probably want is a DataView on your table that you can use as the data source for the grid. That gives you more control over what's presented.
If possible I recommend that you move to a DataGridView for .NET 2.0. It's a lot easier to figure out and you can do more with it with less work.
If it's not possible to switch, this is a good FAQ for Windows Forms in .NET 1.1 and this is an article that addresses how to use table styles and columns. It should get you started.
If you have any questions about the specifics, I'll be happy to help.
If possible I recommend that you move to a DataGridView for .NET 2.0. It's a lot easier to figure out and you can do more with it with less work.
If it's not possible to switch, this is a good FAQ for Windows Forms in .NET 1.1 and this is an article that addresses how to use table styles and columns. It should get you started.If you have any questions about the specifics, I'll be happy to help.
The truth does not change according to our ability to stomach it.
•
•
Join Date: Aug 2007
Posts: 17
Reputation:
Rep Power: 2
Solved Threads: 0
I will presume that you are referring to the datagridview control.(After all this is 2007)
IF you are using Visual Studio 2007 then this is how you can create your own unbound datagridview columns.
> Place a new DataGridView on the form
> Click Properties.
> Scroll to columns and click collection.
> This will fire up the column editor and you can start adding custom columns to your heart's content
IF you are using Visual Studio 2007 then this is how you can create your own unbound datagridview columns.
> Place a new DataGridView on the form
> Click Properties.
> Scroll to columns and click collection.
> This will fire up the column editor and you can start adding custom columns to your heart's content
•
•
Join Date: Aug 2007
Posts: 11
Reputation:
Rep Power: 2
Solved Threads: 0
Hi,
do you want to create DataTable manually and bind it to the datagrid. Here is the code:
#Region "buildDataTable - Building Own DataTable"
Public Function buildDataTable() As DataTable
'Instantiating DataTable object
PrivateDataTable = New DataTable("tblAccounts")
'Create table structure
PrivateDataCol = New DataColumn
PrivateDataCol.ColumnName = "AccName"
PrivateDataCol.DataType = System.Type.GetType("System.String")
'Add column to data table structure
PrivateDataTable.Columns.Add(PrivateDataCol)
'Add column to pk array
PrivateDclPrimaryKey(0) = PrivateDataCol
'Set Primary key
PrivateDataTable.PrimaryKey = PrivateDclPrimaryKey
'Add Debit column
PrivateDataCol = New DataColumn
PrivateDataCol.ColumnName = "Debit"
PrivateDataCol.DataType = System.Type.GetType("System.String")
'Add column to data table structure
PrivateDataTable.Columns.Add(PrivateDataCol)
'Add Credit column
PrivateDataCol = New DataColumn
PrivateDataCol.ColumnName = "Credit"
PrivateDataCol.DataType = System.Type.GetType("System.String")
'Add column to data table structure
PrivateDataTable.Columns.Add(PrivateDataCol)
Return PrivateDataTable
End Function
#End Region
Creating dataTable manually in Visual Basic 2005
do you want to create DataTable manually and bind it to the datagrid. Here is the code:
#Region "buildDataTable - Building Own DataTable"
Public Function buildDataTable() As DataTable
'Instantiating DataTable object
PrivateDataTable = New DataTable("tblAccounts")
'Create table structure
PrivateDataCol = New DataColumn
PrivateDataCol.ColumnName = "AccName"
PrivateDataCol.DataType = System.Type.GetType("System.String")
'Add column to data table structure
PrivateDataTable.Columns.Add(PrivateDataCol)
'Add column to pk array
PrivateDclPrimaryKey(0) = PrivateDataCol
'Set Primary key
PrivateDataTable.PrimaryKey = PrivateDclPrimaryKey
'Add Debit column
PrivateDataCol = New DataColumn
PrivateDataCol.ColumnName = "Debit"
PrivateDataCol.DataType = System.Type.GetType("System.String")
'Add column to data table structure
PrivateDataTable.Columns.Add(PrivateDataCol)
'Add Credit column
PrivateDataCol = New DataColumn
PrivateDataCol.ColumnName = "Credit"
PrivateDataCol.DataType = System.Type.GetType("System.String")
'Add column to data table structure
PrivateDataTable.Columns.Add(PrivateDataCol)
Return PrivateDataTable
End Function
#End Region
Creating dataTable manually in Visual Basic 2005
•
•
Join Date: Oct 2007
Posts: 92
Reputation:
Rep Power: 1
Solved Threads: 8
I guess that your problem is just to change texts of the colums headers right????
Bind your dataGridView
dataGridView.dataSource = dataSource.tables[0];
but in the load event handler, u should precise what the datagridView columns header text should be
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.Columns[0].HeaderText = "Columnname0";
dataGridView1.Columns[1].HeaderText = "Columnname1";
.
.
.
dataGridView1.Columns[n].HeaderText = "Columnnamen";
}
Bind your dataGridView
dataGridView.dataSource = dataSource.tables[0];
but in the load event handler, u should precise what the datagridView columns header text should be
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.Columns[0].HeaderText = "Columnname0";
dataGridView1.Columns[1].HeaderText = "Columnname1";
.
.
.
dataGridView1.Columns[n].HeaderText = "Columnnamen";
}
•
•
Join Date: Jan 2008
Posts: 20
Reputation:
Rep Power: 1
Solved Threads: 0
use this code instead if u want to change the column name of ur table which is displayed in the data grid.
Use this after u give ada.fill(ds);...
Like wise you can give the name you want to the columns of the table...
ds.Tables[0].Columns[0].ColumnName = "Name";
Like wise you can give the name you want to the columns of the table...
•
•
Join Date: Jan 2008
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 1
•
•
•
•
Hi
I want to move the data in a cartein
table to a DataGrid.
What im doing right now is using the:
dataGridView1.DataSource = dataset.Tables[0];
And its adding rows and columns automaticly according to the data base.
(including the headers)
I dont want to do it like that,
i want to design manualy the DataGrid at the beginning.
and then just put the data inside my designed
datagrid, without changing anything or add anything, and without the Headers.
(i want to make my own headers)
How can i do that ?
[im using visual c# with Pervasive.SQL 8]
Thanks.
by using panel
1- make apanel
2- but your datagrid inside panel
3-hide header by panel
4- inside collection of your
![]() |
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Creating DataGrid for Oracle (C#)
- load data from access database into form (VB.NET)
- How to highlight the datagrid row..... (JavaScript / DHTML / AJAX)
- Finding a Record in VB6 ADO (Visual Basic 4 / 5 / 6)
- SOS - datagrid problem (ASP.NET)
- Modify data in Datagrid (VB.NET)
- Urgent Need Help Guys (Visual Basic 4 / 5 / 6)
- How to Show Database In DataGrid Using DAO (Visual Basic 4 / 5 / 6)
Other Threads in the C# Forum
- Previous Thread: Chexk Box Validation..
- Next Thread: How to store this to a dataset


Linear Mode