开发者

ListView and MySQL in WPF

I am trying to do an editable ListView in WPF with a List View, so I found this tutorial with full code on windowsclient.net: http://windowsclient.net/learn/video.aspx?v=83530

And It wor开发者_StackOverflow社区ks great! But, I need it to connect to a remote mysql database on my hosts server, not a local database. Can this be done? Any help at all is appreciated.

Thank you!


Ok I'll explain you for example you need to display the list of data about Person you have the following class

   public class Person
   {
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public int Age { get; set; }
   }

If you need you can implement the INotifyPropertyChanged interface to be able to bind for propeties of class Person also you should use the ObservableCollection (you need to add the reference WindowsBase assembly)

ObservableCollection<Person> persons = new ObservableCollection<Person>();

this persons collection you will use to bind to the ListView

also you need to create the an mapper class for map data from DataSet with data from MySQL into the class Person. I think this is better way to bind the strngly typed collection, but therefore you can use this method Bind to an ADO.NET Data Source


To connect to MySQL data base you should use the MySQL connector

and you will be able to access the data in you code using the ADO.NET technology

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜