Hi
Once again, I'm here about a question about Listview's.
This once should be pretty simple, I need some way of being able to click on a value in the listview, and the 2 following things happen.
1) The value in the Listview is added to a textbox.
2) A function can be added such as hiding a window.
Cheers.
Francis.
22 replies to this topic
#1
Posted 05 December 2011 - 07:58 AM
|
|
|
#2
Posted 05 December 2011 - 10:09 AM
check out the selectedindexchanged event.
#3
Posted 10 December 2011 - 05:06 AM
I've just tryed it, though not quite sure what to do.
I need the selected value from the Listview to be added to a Textbox. When I do this, I get a conversion error.
Could you please give me some example code?
Cheers.
Francis.
I need the selected value from the Listview to be added to a Textbox. When I do this, I get a conversion error.
Could you please give me some example code?
Cheers.
Francis.
#4
Posted 11 December 2011 - 07:46 AM
You add it to the textbox's text property, not the textbox.
#5
Posted 12 December 2011 - 07:57 AM
That creates an error, due to the Listview.SelectedIndexChanged is a System Array?
Do you know of any tutorials for this function?
Do you know of any tutorials for this function?
#6
Posted 12 December 2011 - 08:08 AM
if (listView1.SelectedItems.Count == 1)
{
string logToGet = listView1.SelectedItems[0].Text;
}
{
string logToGet = listView1.SelectedItems[0].Text;
}
#7
Posted 12 December 2011 - 08:15 AM
The code that you put doesn't seem to be in Visual Basic.
THough I have got somewhere at least. I have been using the command "ListViewValue = ListView1.SelectedItems.Item(0)" The only problem that I have with this is that due to this being subbed as System.Windows.Forms.ListViewItem it cannot be added to a textbox. Would you happen to know if there is a way of dimming it to a string without having errors?
Thanks.
Francis.
THough I have got somewhere at least. I have been using the command "ListViewValue = ListView1.SelectedItems.Item(0)" The only problem that I have with this is that due to this being subbed as System.Windows.Forms.ListViewItem it cannot be added to a textbox. Would you happen to know if there is a way of dimming it to a string without having errors?
Thanks.
Francis.
#8
Posted 12 December 2011 - 08:29 AM
Add .Text to Item(0)
#9
Posted 12 December 2011 - 11:45 AM
I've done that. ".Text" is a string, while "Listview1.SelectedItems(0)" is a "System.Windows.Forms.ListviewItem"
#10
Posted 12 December 2011 - 11:56 AM
and Listview1.SelectedItems(0).Text is a string.
#11
Posted 12 December 2011 - 12:05 PM
"Error 1 Value of type 'System.Windows.Forms.ListViewItem' cannot be converted to 'String'. C:\Users\Francis\documents\visual studio 2010\Projects\Remote program\Remote program\Form1.vb 121 25 Remote program
"
That, is the error I get when "Label3.Text = ListViewValue"
Btw, "ListViewValue" = "ListView1.SelectedItems(0)"
"
That, is the error I get when "Label3.Text = ListViewValue"
Btw, "ListViewValue" = "ListView1.SelectedItems(0)"
#12
Posted 12 December 2011 - 12:09 PM
Have you tried ToString()?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









