Struggeling with data bindings of object (no dataset) to TextBox

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,
I am trying to bind data of a business object to a text box as shown below. Unfortunately, if the instance of Photo changes it value, the textbox is not updated.
I subscribed for the Format event (see below), but even thought the instance of Photo changed it values for PhotoPath, the value of e.Value is still empty.
Any advise?
// Constructor of form<br/>
public MainForm()<br/>
{<br/>
// CurrentPhoto is an instance of the class Photo<br/>
// Class Photo has the property "PhotoPath"<br/>
Binding dbPhotoPath = new Binding("Text", m_controler.CurrentPhoto, "PhotoPath",<br/>

true,DataSourceUpdateMode.OnPropertyChanged); <br/>
<br/>
dbPhotoPath.Format += new ConvertEventHandler(DecimalToCurrencyString);<br/>
tbFileName.DataBindings.Add(dbPhotoPath);<br/>
}
private void DecimalToCurrencyString(object sender, ConvertEventArgs e)<br/>
{<br/>
// PhotoPath has a value<br/>
Photo.Photo debug = m_controler.CurrentPhoto;<br/>
string strDebug = debug.PhotoPath;
// strValue is empty<br/>
string strValue = e.Value.ToString();<br/>
}
class Photo : INotifyPropertyChanged<br/>
{<br/>
private string m_strPhotoPath;<br/>
public event PropertyChangedEventHandler PropertyChanged;
<br/>
<br/>
private void NotifyPropertyChanged(String strInfo_p)<br/>
{<br/>
if (PropertyChanged != null)<br/>
{<br/>
PropertyChanged(this, new PropertyChangedEventArgs(strInfo_p));<br/>
}<br/>
}
public Photo(string strPhotoPath_p)<br/>
{<br/>
m_strPhotoPath = strPhotoPath_p;
NotifyPropertyChanged("PhotoPath");<br/>
}<br/>
}



<br/>
<br/>
<br/>


View the full article
 
Back
Top