Re: Programmatically populate grid



I gave that a try. I created my dataset and datatable and populated it
with the data I need.
I bound the dataviewgrid to the dataset, but no records show in my grid. I
have checked the datatable and there are actually records in the table. Am
I missing something? Here is the code I am using:

DataSet dsgrid = new DataSet();

DataTable workTable = new DataTable();

dsgrid.Tables.Add("tablename");

workTable.Columns.Add("field1", typeof(String));

workTable.Columns.Add("field2", typeof(String));

workTable.Columns.Add("field3", typeof(String));

code to populate table

dataGridView1.DataSource = dsgrid.Tables[0];


Thanks,


"Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:%23yjMhUZ6GHA.2364@xxxxxxxxxxxxxxxxxxxxxxx
Tim,

No, there isn't. You need to find a class that implements IList and
then bind to that.

DataSet classes are disconnected data, meaning that you don't need a
database in order to use them. They also have designer support, so you
should just use that in your program and bind to that (populating that
programatically).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Tim Kelley" <tkelley@xxxxxxxxxxx> wrote in message
news:uTyN4kY6GHA.4500@xxxxxxxxxxxxxxxxxxxxxxx
Is it possible to populate a grid using code (not binding it to a
datasource). Is there something like an additem method?

Thanks,







.



Relevant Pages

  • Re: Datagridview.datasource triggers RowsAdded event twice
    ... Later when entering a specific view I will bind a ... So as I understand it the Bindingsource will react when I populate the ... specific view I bind these values to a gridView and react to the RowsAdded ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: whats a neater way of writing this simple code...
    ... I think you could bind an array vs. the array list that would be easier to ... > All I can seem to find on the net is to populate an ArrayList with the ... hear freedom comin" ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: When/Where to load data in DataList Update Template
    ... populate a textbox in the edit template with data, but I found I could do it ... in the template itself by binding it there. ... when I tried to bind it using the properties window, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: combo box problem
    ... You can use combo.ControlSource="yourVar" to bind it to a variable. ... OTOH, I believe you may not need an extra variable?, because you can ... I have a combo box that I populate from a table called ... > capture the users selection and store into a memory variable. ...
    (microsoft.public.fox.vfp.forms)
  • Re: Tables and inserting rows
    ... endorsements would populate for that 1 vehicle. ... Is it possible to rename the bookmark or do I have to use the other option ... Dim myDataBase As Database ... Dim myActiveRecord As Recordset ...
    (microsoft.public.word.vba.general)