Listbox problem
-
I have listbox with the follwing data from the base: rownumber,a1,a2,a3,a4,a5,a6 1 1,2,3,6,5,4 2 3,2,9,5,7,5 3 4,5,2,8,9,7 4 9,9,8,2,3,5 5 9,8,5,1,2,4 6 7,3,6,8,4,9 etc,etc,etc I have 2 textbox textbox1 = the 3rd data in 2nd row textbox2 = the 5th data in 4th row How do I get these by code? can someone help? Tahnks :laugh:
jaakinye
-
I have listbox with the follwing data from the base: rownumber,a1,a2,a3,a4,a5,a6 1 1,2,3,6,5,4 2 3,2,9,5,7,5 3 4,5,2,8,9,7 4 9,9,8,2,3,5 5 9,8,5,1,2,4 6 7,3,6,8,4,9 etc,etc,etc I have 2 textbox textbox1 = the 3rd data in 2nd row textbox2 = the 5th data in 4th row How do I get these by code? can someone help? Tahnks :laugh:
jaakinye
-
I have listbox with the follwing data from the base: rownumber,a1,a2,a3,a4,a5,a6 1 1,2,3,6,5,4 2 3,2,9,5,7,5 3 4,5,2,8,9,7 4 9,9,8,2,3,5 5 9,8,5,1,2,4 6 7,3,6,8,4,9 etc,etc,etc I have 2 textbox textbox1 = the 3rd data in 2nd row textbox2 = the 5th data in 4th row How do I get these by code? can someone help? Tahnks :laugh:
jaakinye
If you know which item you want to get, then you can use ListBox.Items collection. You need to pass the index of the row you are intersted. After getting that value you can split the value using Split method and providing the separator, which will return the string array. Then you can grab the intended the value. :-)
C#:
textBox1.Text = listBox1.Items[1].ToString().Split(new char[] { ',' })[2];
textBox2.Text = listBox1.Items[3].ToString().Split(new char[] { ',' })[4];VB:
textBox1.Text = listBox1.Items(1).ToString().Split(New Char() {","c})(2)
textBox2.Text = listBox1.Items(3).ToString().Split(New Char() {","c})(4) -
If you know which item you want to get, then you can use ListBox.Items collection. You need to pass the index of the row you are intersted. After getting that value you can split the value using Split method and providing the separator, which will return the string array. Then you can grab the intended the value. :-)
C#:
textBox1.Text = listBox1.Items[1].ToString().Split(new char[] { ',' })[2];
textBox2.Text = listBox1.Items[3].ToString().Split(new char[] { ',' })[4];VB:
textBox1.Text = listBox1.Items(1).ToString().Split(New Char() {","c})(2)
textBox2.Text = listBox1.Items(3).ToString().Split(New Char() {","c})(4)