Here is a screenshot of my layout : http://i55.tinypic.com/2z7ifbp.jpg
i need to add the name date time picker and description to listbox and i am inserting them to database thats not the problem.
The problem is when retrieving the data from the listbox as i need to display the information back in their textboxes.
I am only storing the date and name in the listbox as visible.
The description is stored in database.
i need to let the user when press on certain item in list box all the information will be showed in its textbox and date time picker as in database including the Description
Thank You.
Loading
Jean PaulPosted Apr 14, 2011, 6:38 AM
About saving to database - my suggestion would be:
1) On the Add Event button click - save to the db + add to listbox
2) On form load refresh from the db and show in list box
Probably this would answer you queries.
Thanks a lot for the complements.
Mark FenechPosted Apr 14, 2011, 6:10 AM
Because if i add anyevent when i close the program they will be deleted automatically obviously.
Thanks for your help
Mark FenechPosted Apr 14, 2011, 5:58 AM
Goodluck for future .
Jean PaulPosted Apr 14, 2011, 5:29 AM
I would like to appreciate that you put a screen shot that made my job easier.
As you requested, I have attached the code sample. Please have a run on it.
Mark FenechPosted Apr 14, 2011, 5:09 AM
Can you please give me some sample code pleasE ?
Jean PaulPosted Apr 14, 2011, 5:05 AM
I would like to give a small suggestion that the question could be improved.
You can use comma to make the second sentence look like name, datetime etc.
(also I believe date time picker could be changed as datetime only)
Coming back to the problem, first of all I would recommend a good OOPs representation of the solution.
You can use a class named UserEvent with following properties.
class UserEvent
{
public string Name;
public string Description;
public DateTime EventDate;
override ToString()
{
return this.Name + " " + this.EventDate.ToString();
}
}
After this you can create and instance of above class and add to the listbox.
The ToString() method will represent the display of item in listbox.
On selection of the listbox item - you can use the SelectedItem object, cast it into UserEvent and get the description.
Hope you understood the solution.. Please let me know if not i can provide code sample.
Regards,
Jean Paul