[英]Binding Refresh on a dataGrid WinForms
Hey guys I have problem with binding and refreshing binding. 嗨,我在绑定和刷新绑定时遇到问题。
I am using Entity Framework with WindowsForms... 我正在Windows窗体中使用实体框架...
I am retrieving orders from Shipping Queue and binding them to the grid. 我正在从Shipping Queue检索订单并将其绑定到网格。
if I open another form and and move Order X to different Queue, my grid does not reflect that... 如果我打开另一个表单并将Order X移到不同的Queue,则我的网格不会反映出来...
So for example, the Main form has a two grids and a button 因此,例如,主窗体具有两个网格和一个按钮
Grid 1 = Orders in Shipping Queue Grid 2 = Orders in New Order Queue Button 1 = Manage Orders
If I click my "Manage Orders" button and open up Order X that is in the Shipping Queue and move it to the New Orders Queue, I want the change to be reflected in the grids. 如果单击“管理订单”按钮并打开“发运队列”中的“订单X”,然后将其移至“新订单”队列中,则希望更改反映在网格中。
I tried different stuff and the cheapest and best solution I came up with was to call update on the grids every few minutes but I feel that there must be a better way... 我尝试了不同的方法,想到的最便宜,最好的解决方案是每隔几分钟调用一次网格更新,但是我觉得必须有更好的方法...
Any thoughts? 有什么想法吗?
Ensure that the values you're binding to are calling OnPropertyChanged() properly. 确保您绑定到的值正确调用OnPropertyChanged()。
public class Class1 : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private int myValue;
public int MyValue
{
get { return myValue; }
set
{
if (myValue != value)
{
myValue = value;
OnPropertyChanged("MyValue");
}
}
}
protected virtual void OnPropertyChanged(string property)
{
var notify = PropertyChanged;
if (notify != null)
notify(this, new PropertyChangedEventArgs(property));
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.