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
Printable View
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
:confused: huh?Quote:
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
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
Some sort of this....but display all at the same time in listbox..
is it possible...
Then use ListBox1.Items.Add() instead of Console.WriteLine
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
i don't quiet get what you mean but does this help?
:bigyello: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
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 ).Quote:
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
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.
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...
How to arrange the list box to appear like below after i add the items to itCode: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
Peter
10/2/04
------------
John
11/2/04
-------------
instead of
Peter
John
10/2/04
112/04
is it possible....
Thanks
Can't you just do it like this?
Or are you wanting it to show up like that and be the same selected item index?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
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
But what if more than one nodes is select using
can it be achieve also...Code:doc.SelectNodes("//Book/Title/Page")
doc.SelectNodes("//Book/Title")