|
-
Sep 28th, 2004, 10:13 AM
#1
Thread Starter
Addicted Member
VB.NET: Question on presenting array
If i have a list of arrays, how to go about viewing every individual of it...
Say inside each of the array has this content:
Name: OO
Age: XX
how to you guys present the dynamic arrays or arrays on one form in your Window application......
Thanks
Last edited by toytoy; Sep 28th, 2004 at 10:16 AM.
-
Sep 28th, 2004, 11:45 PM
#2
Addicted Member
Re: VB.NET: Question on presenting array
Originally posted by toytoy
If i have a list of arrays, how to go about viewing every individual of it...
Say inside each of the array has this content:
Name: OO
Age: XX
how to you guys present the dynamic arrays or arrays on one form in your Window application......
Thanks
huh?
Do you mean you want to display the contents of an array?
Code:
Dim i as Integer
Dim Array(2) as String
Array(0) = "Name: OO"
Array(1) = "Age: XX"
For i = 0 to UBound(Array)
Console.Writeline(Array(i)
Next
-
Sep 29th, 2004, 12:00 AM
#3
Thread Starter
Addicted Member
Some sort of this....but display all at the same time in listbox..
is it possible...
-
Sep 29th, 2004, 12:14 AM
#4
Then use ListBox1.Items.Add() instead of Console.WriteLine
-
Sep 29th, 2004, 02:00 AM
#5
Thread Starter
Addicted Member
cannot...
it is ok if i am using listbox to display....
but say i want to selected from one block of array..
the listbox can only select either the name or age..
it cannot select both name and age together..
any other control can i use to display and then select from it..
Thanks
Last edited by toytoy; Sep 29th, 2004 at 02:05 AM.
-
Sep 29th, 2004, 02:13 AM
#6
Fanatic Member
i don't quiet get what you mean but does this help?
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
Dim p() As person = {New person("toytoy", 10), New person("mendhak", 12)}
For i = 0 To UBound(p)
ListBox1.Items.Add(p(i).name & " " & p(i).age.ToString())
Next
End Sub
Structure person
Dim name As String
Dim age As Integer
Sub New(ByVal name As String, ByVal age As Integer)
Me.name = name
Me.age = age
End Sub
End Structure
Last edited by brown monkey; Sep 29th, 2004 at 02:19 AM.
-
Sep 29th, 2004, 06:29 AM
#7
PowerPoster
Re: VB.NET: Question on presenting array
Originally posted by toytoy
If i have a list of arrays, how to go about viewing every individual of it...
Say inside each of the array has this content:
Name: OO
Age: XX
how to you guys present the dynamic arrays or arrays on one form in your Window application......
Thanks
It is only the final rank of an array which can be used to store data. So, you will either have to have multiple elements in the final rank or do as brown monkey posted and use a structure (or a custom class ).
You can then loop through the array, extracting and concanting the information you require and adding it to the listbox. You can loop through the array in as many segments as you require, e.g. one at a time; blocks of five at a time or the whole lot.
I have assumed that what you meant in your final post was that you want to select both name and age simultaneously.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Sep 29th, 2004, 10:56 AM
#8
Thread Starter
Addicted Member
VB.NET: How to arrange the listbox display using XmlDocument
But what if i want to use XmlDocument and extract the nodes to create an arraylist in the listbox...
Say i use XmlDocument Method to select the nodes...
Code:
For Each n In xdoc.SelectNodes("//Book/Title")
a = "Author : " & n.Attributes("Author").Value
lst3.Items.Add(a)
Next
For Each n In xdoc.SelectNodes("//Book/Title")
b = "Date : " & n.Attributes("Date").Value
lst3.Items.Add(b)
Next
How to arrange the list box to appear like below after i add the items to it
Peter
10/2/04
------------
John
11/2/04
-------------
instead of
Peter
John
10/2/04
112/04
is it possible....
Thanks
Last edited by toytoy; Dec 3rd, 2004 at 08:07 AM.
-
Sep 29th, 2004, 12:02 PM
#9
Addicted Member
Can't you just do it like this?
Code:
For Each n In xdoc.SelectNodes("//Book/Title")
a = "Author : " & n.Attributes("Author").Value
b = "Date : " & n.Attributes("Date").Value
lst3.Items.Add(a)
lst3.Items.Add(b)
lst3.Items.Add("-------------")
Next
Or are you wanting it to show up like that and be the same selected item index?
If thats the case, I don't believe you can hve multiple lines with the same index.
You would have to display the data like:
Code:
For Each n In xdoc.SelectNodes("//Book/Title")
a = "Author : " & n.Attributes("Author").Value
b = "Date : " & n.Attributes("Date").Value
lst3.Items.Add(a & " - " & b)
Next
Last edited by rdove; Sep 29th, 2004 at 12:06 PM.
-
Sep 29th, 2004, 12:17 PM
#10
Thread Starter
Addicted Member
But what if more than one nodes is select using
Code:
doc.SelectNodes("//Book/Title/Page")
doc.SelectNodes("//Book/Title")
can it be achieve also...
Last edited by toytoy; Dec 3rd, 2004 at 08:07 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|