|
C# .Net 2005 - Question about .Row.Add(new object[]{})
|
|
23-02-2006, 09:22 AM
Post: #1
|
|||
|
|||
|
C# .Net 2005 - Question about .Row.Add(new object[]{})
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: Code: public frmBA() 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, 09:34 AM
Post: #2
|
|||
|
|||
Re: C# .Net 2005 - Question about .Row.Add(new object[]{})
jcrcarmo Wrote: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? What tables? If you mean that all these things are stored in a database, then yes, that's easy to use as your datasource. Hopefully, you have something along the lines of SQL Server. If you have Access or a spreadsheet or something horrible like that, then I would suggest downloading SQL 2005 Express, which is free from Microsoft and importing into a fresh database, as it will frankly save you much time and hassle. The class library of choice is, IMHO, SqlHelper. It's very good for one-liners that read the results of a SQL stored procedure into a datatable object. From there you can do with the tables as you like, really. The following article seems ok for an intro: http://aspnet.4guysfromrolla.com/articles/070203-1.aspx Hope that helps! *edit* Alternatively your SementesDT data seems to have a very common pattern: Code: sementesDT.Rows.Add(new object[] { 0, 0, "SubCat0-Cat0" });Why not set up a loop that adds objects three at a time, and builds the final string as it goes? E.g... Code: int groupCount = 0;Give me liberty, or give me death - Patrick Henry 1775. Think for yourselves and let others enjoy the privilege to do so too - Evelyn Beatrice Hall 1906 I spread my wings, only to find that they are paper in the rain - Neko 2006 |
|||
|
23-02-2006, 10:03 AM
Post: #3
|
|||
|
|||
|
Hi Neki,
Thanks for your quick reply. The table I'm talking about is the tabSementes: sementesDT = new DataTable("tabSementes"); as referenced in the code I posted. I will study the code that you posted, but please don't overestimate my C# habilities. I'm still a newbie! Hehehehe ... Thanks! JC
|
|||
|
23-02-2006, 12:00 PM
Post: #4
|
|||
|
|||
|
Heh no prob, everyone starts somewhere
![]() I think I'm a little lost though... is it that you want to be able to duplicate data from one table to another? Give me liberty, or give me death - Patrick Henry 1775. Think for yourselves and let others enjoy the privilege to do so too - Evelyn Beatrice Hall 1906 I spread my wings, only to find that they are paper in the rain - Neko 2006 |
|||
|
23-02-2006, 03:40 PM
Post: #5
|
|||
|
|||
|
Hi Neko,
Let me explain of I'm trying to do: the code I posted filters the data displayed in a comboBoxColumn in a DataGridView depending on the value I select a from another comboBoxColumn in the same DataGridView. Everything is working, BUT if I have to manually enter more than 500 values for the second ComboBoxColumn, it would leave much room for mistakes, since the names are all in Latin. My tabSementes doesn't really have a common pattern. That was just an example. Here's a more accurate representation: Code: public frmBA() Do you have any suggestions? Thanks a lot! JC |
|||
|
23-02-2006, 03:46 PM
Post: #6
|
|||
|
|||
|
Hi Neko,
It's me again. I forgot to ask you this: is it possible to do that loop to load the values if theuy are all different strings? What would be the code for it? Thanks a million! JC
|
|||
|
23-02-2006, 09:15 PM
Post: #7
|
|||
|
|||
|
What to do now depends on what form you have your data for sementes. If it's a database, we can do that easily, see above post on SqlHelper
![]() Spreadsheets, text files, or XML can all be read through various means, but none is as friendly. It is however, better than hardcoding them all, as it would let you add rows or correct spelling errors without recompiling the code. You can't loop for unpredictable strings - you'd still have to load the proper strings from somewhere. Give me liberty, or give me death - Patrick Henry 1775. Think for yourselves and let others enjoy the privilege to do so too - Evelyn Beatrice Hall 1906 I spread my wings, only to find that they are paper in the rain - Neko 2006 |
|||
|
« Next Oldest | Next Newest »
|

Search
Member List
Calendar
Help




