borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (C# 2005 - Problem publishing application)Next Topic (How to display images in datagrid from database) New Topic New Poll Post Reply
AndreaVB Forum : C# : C# .Net 2005 - Question about .Row.Add(new object[]{}) Please help!
Poster Message
jcrcarmo
Level: Protégé

Registered: 22-02-2006
Posts: 6

icon C# .Net 2005 - Question about .Row.Add(new object[]{}) Please help!

Hello everyone,

Greetings from Brazil!  As shown in the code below, is it possible for me to add the new objects for tipoDT and sementesDT without having to do it one-by-one?  Like, for example, getting the values automatically from the tables?....  How would I do that?  The sementesDT table is quite large and would take me forever to add the new objects one-by-one!  Here's the code:


       public frmBA()
       {
           tipoDT = new DataTable("tabTipoSemente");
           tipoDT.Columns.Add("CodTipo", typeof(int));
           tipoDT.Columns.Add("Tipo", typeof(string));

           tipoDT.Rows.Add(new object[] { 0, "Nocivas Probidas" });
           tipoDT.Rows.Add(new object[] { 1, "Nocivas Toleradas" });
           tipoDT.Rows.Add(new object[] { 2, "Sementes Silvestres" });

           sementesDT = new DataTable("tabSementes");
           sementesDT.Columns.Add("CodSemente", typeof(int));
           sementesDT.Columns.Add("CodTipo", typeof(int));
           sementesDT.Columns.Add("Semente", typeof(string));

           sementesDT.Rows.Add(new object[] { 0, 0, "SubCat0-Cat0" });
           sementesDT.Rows.Add(new object[] { 1, 0, "SubCat1-Cat0" });
           sementesDT.Rows.Add(new object[] { 2, 0, "SubCat2-Cat0" });
           sementesDT.Rows.Add(new object[] { 3, 1, "SubCat3-Cat1" });
           sementesDT.Rows.Add(new object[] { 4, 1, "SubCat4-Cat1" });
           sementesDT.Rows.Add(new object[] { 5, 1, "SubCat5-Cat1" });
           sementesDT.Rows.Add(new object[] { 6, 2, "SubCat6-Cat2" });
           sementesDT.Rows.Add(new object[] { 7, 2, "SubCat7-Cat2" });
           sementesDT.Rows.Add(new object[] { 8, 2, "SubCat8-Cat2" });

           InitializeComponent();

           tipoBS = new BindingSource();
           tipoBS.DataSource = tipoDT;
           TipoComboBoxColumn.DataSource = tipoBS;
           TipoComboBoxColumn.DisplayMember = "Tipo";
           TipoComboBoxColumn.ValueMember = "CodTipo";

           unfilteredSementesBS = new BindingSource();
           DataView undv = new DataView(sementesDT);
           unfilteredSementesBS.DataSource = undv;
           EspecieComboBoxColumn.DataSource = unfilteredSementesBS;
           EspecieComboBoxColumn.DisplayMember = "Semente";
           EspecieComboBoxColumn.ValueMember = "CodTipo";

           filteredSementesBS = new BindingSource();
           DataView dv = new DataView(sementesDT);
           filteredSementesBS.DataSource = dv;
       }



Thank you very much for your attention, time and help and I'm looking forward to your reply.

Best regards,

JC Carmo  

23-02-2006 at 06:59 AM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: C# .Net 2005 - Question about .Row.Add(new object[]{}) Please help!

I am not following you..... Are you are trying to say that you will have lots of lines of code, and you want to reduce the number of lines? If so, then it can be done with a for----loop routine, but it will still be adding one object at a time...

____________________________
If you find the answer helpful, please mark this topic as solved.

23-02-2006 at 08:01 PM
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: C# .Net 2005 - Question about .Row.Add(new object[]{}) Please help!

Hi.
You appear to be using a dataset. Instead of new object[] try using new DataRow?
K


____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

24-02-2006 at 12:30 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : C# : C# .Net 2005 - Question about .Row.Add(new object[]{}) Please help!
Previous Topic (C# 2005 - Problem publishing application)Next Topic (How to display images in datagrid from database) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder