Well, it's not quite what I'm looking for.
When the actual user of the program selects a person that is found in the
ListBox, all the contents on the form change; for example, the First Name
TextBox, the LastName TextbBox. Etc.
It changes by the following event...
private void ListBoxPerson_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.ListBoxPerson.SelectedIndex >= 0)
{
this.cm.Position = this.ListBoxPerson.SelectedIndex;
}
}
NOTE: this.cm is the CurrencyManager.
This allows the controls on the page to dynamically change. However, the
Person also has an Array of tasks that were completed. I'm trying to
dynamically change the DataGridView too with respect to the change of index
of the ListBoxPerson.]
Trecius
"Peter Duniho" wrote:
> On Thu, 07 May 2009 11:46:17 -0700, Trecius
> <(E-Mail Removed)> wrote:
>
> > [...]
> > How can I make it so I that when the Person is changed in the Listbox,
> > the
> > DataGridView will also change the third, or last, column?
>
> Do you mean when the specific Person object changes, or when the "person"
> selected in your ListBox changes (i.e. the ListBox selection changes)?
> Why is the CurrencyManager relevant at all?
>
> > On a short note, I can populate the first two rows, using my dictionary,
> > as
> > follows:
> >
> > BindingSource bind = new BindingSource();
> > bind.DataSource = dictTasks;
> > GridView1.DataSource = bind;
> >
> > However, how should I get my last column in there that corresponds to the
> > Person completing the job or not? Thank you.
>
> Hard to say what the best approach is. I suppose you could create a
> wrapper class that implements, for example, IBindingList, and then
> provides a unified view onto the dictionary and associated data via a
> specific element type. But whether that's most appropriate in your
> situation, no one can say because you didn't bother to post a
> concise-but-complete code example that reliably demonstrates what's going
> on.
>
> The short answer is: you'll need some kind of "change" event somewhere to
> update things automatically based on changes elsewhere in your data. If
> you simply need an update based on a ListBox selection change, that's
> easy, as ListBox already exposes such "change" events. If you need an
> update based on when a specific Person object changes, then either your
> Person object itself needs to have a "change" event, or you need some
> mediator that knows when the Person object changes and can be used to
> raise an event or otherwise update the UI.
>
> Of course, all of that is probably pretty obvious. But that's about as
> much advice as anyone can give in response to such a vague question.
>
> Pete
>
|