You want databinding.
Say we have a simple class:
class ClassA
members - string name
methods - public override ToString(){return name;}
// the override is so that the name is shown in the listbox when used as
datasource
// as the listbox displaymember defaults to ToString()
ClassA ca = new ClassA("AName");
ArrayList al = new ArrayList();
al.Add(ca);
this.listBox1.SelectedIndexChanged+=new EventHandler(list_IndexChanged);
this.listBox1.DataSource = al;
private void list_IndexChanged(object sender, EventArgs e)
{
if(null != this.listBox1.SelectedItem)
{
this.textbox1.DataBindings.Clear();
ClassA ca = (ClassA) listBox1.SelectedItem;
this.textbox1.DataBindings.Add("Text", ca, "Name");
//// usage is property to map to ("Text") object to map (ca) and property to
map ("Name")
}
}
This will update the changes as soon as the textbox is modified.
This is just psudeo code so it might not work if you copy and paste but the
concept is there.
HTH
Jax
"I_Chameleon" <na***********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi,
Is there a way to call a method on index A as soon as the user clicks
on index B in a ListBox?
This is my particular scenario: I have a ListBox of records in one
panel and a TextBox containing Text associated with
ListBox.SelectedIndices[0]. I want the record to be updated (in an
ArrayList, file, whatever) as soon as that index is no longer selected.
I do not want the user needing to click a Save button.
Thank you.