Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C#

C# C# Discussion

Reply
 
Thread Tools Display Modes
Old 01-06-2007, 12:58 AM   #1 (permalink)
Forum Expert
 
Join Date: Dec 2003
Location: Sitting in a chair fulfilling my life's goal
Age: 22
Posts: 2,650
Send a message via AIM to Killamus Send a message via MSN to Killamus
Default Method to do this:

Is it possible...
Stupid question.
How would I make a method that would add new textboxes, etc, when a button is pressed? I can't think of anything, because each new textbox requires a new name, and I can't figure out how to make that. Normally I'd just manually make it myself, but alas, it would have upwards of thousands of fields....

Also, how would I save a group of combo box, text box, and date box fields to a file, or even in the program itself? Preferably outside, but inside work. Anyone know a method to do this?
__________________
Procrastinators unite!
Tomorrow.
Saying that Java is nice because it works on all OS's is like saying that anal sex is nice because it works on all genders.
Killamus is offline   Reply With Quote
Old 01-08-2007, 03:13 PM   #2 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
Default

Well, what exactly happens when the button is pressed? Is it getting information from somewhere or just creating a random textboox?
Just use that info to generate a name for control (although are you sure you need a unique name for each control?)

Anyways, once you have created the control, add it to a List<Control> that will store all the textboxes (or any other controls) you create, then to access them you can use the many methods that List provides, either by cycling them them, accessing them by their index, etc.

And to save the data, you can always use serialization.
mordero is offline   Reply With Quote
Old 01-08-2007, 04:06 PM   #3 (permalink)
Forum Expert
 
Join Date: Dec 2003
Location: Sitting in a chair fulfilling my life's goal
Age: 22
Posts: 2,650
Send a message via AIM to Killamus Send a message via MSN to Killamus
Default

I'm trying to create something akin to a checkbook.

Fields are:
Date/time, withdraw/deposit, amount, where spent.

Problem is, I, personally, make 2-3 withdraws/deposits a day, be it lunch or something... but either way. That amounts to 90 a month, like 1000 a year. So, instead of making 1000 textboxes/date/time boxes, isn't there a method I can use, that would generate a text box? It doesn't need an individual name, I just need to be able to get the amount inserted.
__________________
Procrastinators unite!
Tomorrow.
Saying that Java is nice because it works on all OS's is like saying that anal sex is nice because it works on all genders.
Killamus is offline   Reply With Quote
Old 01-08-2007, 04:33 PM   #4 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
Default

yeah when you click the button have it call a method similar to this (youll have to adjust to create multiple controls):

Need a List<TextBox> boxes = new List<TextBox>();
along with a method that will control your textchange event
Code:
TextBox box = new TextBox();
box.Name = [some date/time you that will be the unique name for this textbox in this list]
box.TextChanged +=newEventHandler(box_TextChanged);
controls.Add(box);
now how you "hold" the different fields is up to you, but creating a different list for each field is about the only thing i can think of right now.

Also, look into a TableLayoutPanel and how it works, because you could use that to set up how your controls appear without have to deal with the coordinates of all of these textboxes (it will do it automatically).

Ohhh I didnt update the code, but just thought of this, use a dictionary that has the date time as its key and the textbox for its value, then you could use that for the lookup of the day and such.

For saving, depending on how fast it is, looking into using XML for storage, it isng difficult with .net

hope that helps...
mordero is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5