[C#] MySQL view in listbox and some other question..
#3

Create a class Entity for the database Table

class t_magic{
//class properties
//depending on the method of access if you dont wan
private int a_index;
private string a_name;
//...
//class methods interface methods(add this if the properties are private)
public int Index{
get{
return a_index;
}
set{
a_index = value;
}
}
public string Name{
get{
return a_name;
}
set{
a_name = value;
}
}
//...
}

 

Then create a linked list for the t_magic class:

//...
//public or private depends on how you want to access it.
private Static LinkedList t_magicList = new LinkedList();
//....
//note mysqlclass does not exist if you will look for it its something invented on the spot Just for this example.
for(int i = 0;i < mysql.QuerySize;i++){
t_magic magic = new t_magic();
magic.Index = mysql.getInt("a_index");
magic.Name = mysql.getString("a_name");
//...
t_magicList.add(magic);
mysql.nextRow();
}

 

And inserting the data into list would be:

List myList = new List();

for(int i = 0;i < t_magicList.Count; i++){
t_magic magic = new t_magic();
magic = t_magicLis[i];
myList.add(magic.Index + " "+magic.Name);
}
listbox1.DataSource =null; //empty listbox1
listbox1.DataSource = myList; //add new data to it

 

According to Selected index on the listbox1 you could edit the data from t_magicList, and then send it to the database.



Messages In This Thread
[No subject] - by Nikolee - 05-15-2012, 11:54 AM
[No subject] - by Nikolee - 05-15-2012, 12:13 PM
[No subject] - by someone - 05-15-2012, 01:04 PM
[No subject] - by Wizatek - 05-15-2012, 02:18 PM
[No subject] - by SibaN - 05-17-2012, 08:52 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)