I have a application im working on that uses the Jabber Libraries to connect to a jabber Server and receive contacts etc.
I have buit all login system and interface for the chat but now im working on how to Bind the data for the contacts to the ListView
I have a function that is called when a contact comes online such, See Below
//AppController.cs
public void XmppConnection_OnRosterItem(Object Sender, RosterItem RosterItem)
{
if (LoginWindow.ActiveForm.InvokeRequired)
{
LoginWindow.ActiveForm.BeginInvoke(
new XmppClientConnection.RosterHandler(XmppConnection_OnRosterItem),
new object[] { Sender, RosterItem}
);
return;
}
//UPDATE HERE
}
The idea is to have a class such as ContactList so that when the above function is called i can go ContactList.AddRoster(Roster);
What i need to know is how do I create a custom list class and then bind it to the the Form witch holds the ListView element
And if possible set an update interval to recompile the ListVeiw?
Hope you guys can help me
Edit:
If I could have 2 classes one for the individual contact and one to hold the collection like so:
Contact C = new Contact(Roster.Name,Roster.Jid,Roster.Group);
ContactList.Add(C);
This as well would be good.
You could create a Contact class the just create a List of Contacts
How to Bind ListView to List
http://www.vistax64.com/avalon/615-how-bind-listview-list-mystruct.html
Not sure about the update interval though. Attach it to a certain event and check the time in between maybe? MouseMove (Performance Cost?)
Anyone else have any ideas?
EDIT:
You shouldn’t need to add anything to this class
Overiding the ToString function allows you easier control over what is displayed in the listbox
Let me know if this works for you.