private void listBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
string selected = Path.GetFileName(lblist.IndexFromPoint(e.Location).ToString());
foreach (ListBox i in lblist2.Items)
{
if (selected == i.Name)
{
lblist2.SelectedIndex = i.SelectedIndex;
}
}
}
}My application has two listboxes. listbox1 shows me full file paths. listbox2 shows me only filenames.On first i click the slected item.
I want to find on listbox2 the same string and sekect it as in listbox1 . I wrote this code, however i stuck and of course it doesn't work. I tried. Help.


Sign In
Create Account


Back to top









