Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

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

Posted

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

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 :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...