|
||
|
|
#1 (permalink) |
|
Forum Expert
|
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. ![]() |
|
|
|
|
|
#2 (permalink) |
|
Forum Expert
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
|
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. |
|
|
|
|
|
#3 (permalink) |
|
Forum Expert
|
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. ![]() |
|
|
|
|
|
#4 (permalink) |
|
Forum Expert
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
|
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); 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... ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|