Hi Soul,
Do you understand my meanning?
You should use the simplest program logic to add your treenode through
"for" statement.
You should add the root nodes first(loop through Year column), then add the
second level nodes(loop through the Semester column)....
If you still feel anything unclear, please feel free to let me know.
Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
| Reply-To: "Soul" <so********@antisocial.com>
| From: "Soul" <no@spam.com>
| References: <us**************@TK2MSFTNGP12.phx.gbl>
| Subject: Re: Logic for TreeView
| Date: Wed, 8 Oct 2003 01:41:07 +1000
| Lines: 81
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="utf-8"
| Content-Transfer-Encoding: 7bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <uF**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: dsl-203-113-207-187.vic.netspace.net.au 203.113.207.187
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:189585
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| My test codes are as follow, but obviously I am wrong as it come out with
8
| times of 2003 and in each 2003, it will contain 5 times of semester one, 3
| times of semester two.
|
| for (int i = 0; i < this.dataSet.Tables[0].Rows.Count; i++)
| {
| TreeNode yearNode = this.treeView.Nodes.Add("Year: " +
| this.dataSet.Tables[0].Rows[i]["subjectYear"].ToString());
| dataView.RowFilter = "subjectYear = " +
| this.dataSet.Tables[0].Rows[i]["subjectYear"].ToString();
|
| foreach (DataRowView row1 in dataView)
| {
| TreeNode semesterNode = yearNode.Nodes.Add("Sem: " +
| row1["subjectSemester"].ToString());
| dataView.RowFilter = "subjectSemester = " +
| row1["subjectSemester"].ToString();
|
| foreach (DataRowView row2 in dataView)
| {
| TreeNode codeNode =
| semesterNode.Nodes.Add(row2["subjectCode"].ToString());
| }
| }
| }
|
| --
| Soul
|
|
| "Soul" <no@spam.com> wrote in message
| news:us**************@TK2MSFTNGP12.phx.gbl...
| | Hi,
| |
| | I am learning C# at the moment. I am trying to develop a simple program
| that
| | will get data from a MS Access database into a dataSet. The result of
| | dataSet should be something like:
| |
| | Year Semester Code Task
| | ---------------------------------------------------
| | "2003" "One" "CSE9020" "Deliverable Item 1"
| | "2003" "One" "CSE9020" "Deliverable Item 2"
| | "2003" "One" "CSE9020" "Deliverable Item 3"
| | "2003" "One" "CSE9020" "Deliverable Item 4"
| | "2003" "One" "CSE9020" "Deliverable Item 5"
| | "2003" "Two" "CSE9020" "Deliverable Item 1"
| | "2003" "Two" "CSE9020" "Deliverable Item 2"
| | "2003" "Two" "CSE9020" "Deliverable Item 3"
| |
| |
| | Now I have to populate a TreeView from the dataSet. I have learnt how to
| | populate TreeView Nodes from
| |
http://www.codeproject.com/cs/database/2dtreeview.asp and some other
| online
| | examples. But I am struggling to come out with the programming logic so
| that
| | I may populate a TreeView Nodes like:
| |
| | -Year
| | - Semester
| | - Code
| | - Task
| | - Semester
| | - Code
| | - Task
| | - Code
| | - Task
| | - Task
| | - Year
| |
| | Can someone give me some hint?
| |
| | Thank you.
| |
| | --
| | Soul
| |
| |
| |
|
|