Hello Everybody:
I am trying to select a Row in a ListView and display it on a textbox. However I am not getting the syntax right.Can any body tell me whats wrong?
The code compiles .However when I select the row on the ListBox
it does not display on the textBox.. I am selecting the row on the list view control....it should display on the txtSend.Text
Originally posted by Rahils573 The code compiles .However when I select the row on the ListBox
it does not display on the textBox.. I am selecting the row on the list view control....it should display on the txtSend.Text
Pls guide...
Should we use listViewClients.FullRowSelect???
Pls guide..
Rahil
I assume you mean Listview not listbox . I created a little example . check it out .
The only difference I could finf between yours and my application is that you are adding the values in the Items (aaa,bbb, ccc) Collections.
Mine is a Client -Server application in which the information is sent by the client to the server.The information is stored in the list view on the server.So the information is added at Run time .
I do not know whether that is creating any difference.
Adding values at runtime or design time won't make any difference . Both ways would add the item to the collection obj of the listview therefore , has it's own index number .
Are you getting specific error or anything that make sense ?
Your problem was with attaching the event handler to the listview . To fix this do the following :
1-Click the listview , then go the properties window , click the yellow icon on the right (events) . Then scroll to Click and doubleclick it . Then copy this code :
PHP Code:
for( int i = 0 ;i< this.listViewClients.Items.Count ;i++)
{
if (listViewClients.Items[i].Selected == true)
{
this.textBox1.Text=listViewClients.SelectedItems[0].Text;
}
}
in the istViewClients_Click generated event . Then you should see your program working fine.