Re. Updating DataViews

T

Terry McNamee

Hi Nicholas,

To give you a better understanding of what I'm doing...

I'm using a ownerdrawnlist control that is used as a menu on the smartphone.
To populate this menu, I iterate through the DataTable by:

foreach (DataRowView row in view)

{

dataMenu.Items.Add(new DataItem(row["Name"].ToString(),
row["File"].ToString()));

}

The trouble I'm experiencing, is when I add change the datatable in any way,
I need to update my ownerdrawnlist control. I'm using a view to sort the
datatable alphabetically, and then I want to iterate through the view
populating my table.

I appreciate your assistance.


Terry McNamee said:
Hi Nicholas,

How can I determine when the DataTable is changed ?

Basically what i need to do is call the populateMenu method once the
DataTable is changed.

I understand what you're saying about the paint methods, but the
populateMenu method goes through the view and adds each item to my
customised menu.

Thanks.



Nicholas Paldino said:
Terry,

When the DataTable is changed, your event handler should call the
Invalidate method on the control you need repainted. Then, that control
should have an event handler for the Paint event, or an override of the
OnPaint method. In that, you will have your code that paints your screen
(this causes your screen to be painted correctly when needed).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Terry McNamee said:
I have a DataTable which i have added data to.

I have a custom method that prints a DataView of the DataTable out on
the screen. The problem I'm having is, i need to call the custom method
whenever the DataTable is changed.

How can I do this? this is not a standard binding problem, since I need
to call a custom method to paint the items on the screen.

view.ListChanged += new ListChangedEventHandler(this.view_Changed);



private void view_Changed(object sender,
System.ComponentModel.ListChangedEventArgs e)

{

this.populateMenu(); //we want to populate the menu again.

}

Many thanks.
 
N

Nicholas Paldino [.NET/C# MVP]

Terry,

You can hook up to the RowChanged event to see when something new is
added, then invalidate your listview when you receive the RowChanged event.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Terry McNamee said:
Hi Nicholas,

To give you a better understanding of what I'm doing...

I'm using a ownerdrawnlist control that is used as a menu on the
smartphone.
To populate this menu, I iterate through the DataTable by:

foreach (DataRowView row in view)

{

dataMenu.Items.Add(new DataItem(row["Name"].ToString(),
row["File"].ToString()));

}

The trouble I'm experiencing, is when I add change the datatable in any
way,
I need to update my ownerdrawnlist control. I'm using a view to sort the
datatable alphabetically, and then I want to iterate through the view
populating my table.

I appreciate your assistance.


Terry McNamee said:
Hi Nicholas,

How can I determine when the DataTable is changed ?

Basically what i need to do is call the populateMenu method once the
DataTable is changed.

I understand what you're saying about the paint methods, but the
populateMenu method goes through the view and adds each item to my
customised menu.

Thanks.



Nicholas Paldino said:
Terry,

When the DataTable is changed, your event handler should call the
Invalidate method on the control you need repainted. Then, that control
should have an event handler for the Paint event, or an override of the
OnPaint method. In that, you will have your code that paints your
screen
(this causes your screen to be painted correctly when needed).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

"Terry McNamee" <n/a> wrote in message
I have a DataTable which i have added data to.

I have a custom method that prints a DataView of the DataTable out on
the screen. The problem I'm having is, i need to call the custom
method
whenever the DataTable is changed.

How can I do this? this is not a standard binding problem, since I
need
to call a custom method to paint the items on the screen.

view.ListChanged += new ListChangedEventHandler(this.view_Changed);



private void view_Changed(object sender,
System.ComponentModel.ListChangedEventArgs e)

{

this.populateMenu(); //we want to populate the menu again.

}

Many thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top