Adding a complete Column to a Datagridview?!

Twister

Newcomer
Joined
Jul 11, 2003
Messages
6
Hello,

I'm working with VB.net 2005 and I'm using Datagridview. What I would like to do is to add a complete column (not only the header!). I know its possible to do the following:
Code:
Dim row0 As String() = {"6/30/1992", "3", "Dress", "P J Harvey", "Dry"}
    With Me.dataGridView1.Rows
        .Add(row0)
    End With
(Found this in Documentation)
But can I do this with Colums too?
Sorry if this is a stupid question...

Thanks in Advance,
Twister
 
Not that I know of - ie as you have done there.
What you could do is have the data you want to add in the column in an array and then loop through... ie
Code:
string[] strExample = new string[] { "one", "two", "three" };

foreach( string strSingle in strExample )
{
     drNewRow = dtDataTable.NewRow();
     drNewRow[ intOfColumnYouAreAddingDataToo ] = strSingle;
     dtDataTable.Rows.Add( drNewRow );
}

Im pretty new to all this C# stuff, but if I wanted to populate a single column in a datatable thats what I'd do :)
 
Back
Top