aewarnick Posted February 10, 2003 Posted February 10, 2003 (edited) I need to make a program that has the capasity to add object permanantly to the form (unless they choose to delete it). I tried this but it does not work: Control r=new RichTextBox(); r.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); r.Location = new System.Drawing.Point(80, 162); r.Name = "richTextBox3"; r.Size = new System.Drawing.Size(520, 56); r.TabIndex = 3; r.Text = "richTextBox3"; And they would need the ability to move and resize them too. How would I do this? Edited February 10, 2003 by divil Quote C#
*Gurus* divil Posted February 10, 2003 *Gurus* Posted February 10, 2003 You're almost there. Your code will work, but you need to add the following line to the end: Controls.Add(r); As for moving and resizing, you will have to write all this logic yourself, including drawing the selection rectangles and adjusting sizes when the user drags the mouse. It's not a trivial task, but the ControlPaint class may help with some of the drawing. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted February 10, 2003 Author Posted February 10, 2003 Thank you. How would the user permanantly save it to the program? And, when the user add a box, how would I make it so that the boxes would only go to a specific place? For example: The user has a peoples names area on the form for the peoples names to be entered and all the rest is something else. How would I specifically put them in a locatioin right after the last box in that area? Quote C#
*Gurus* divil Posted February 10, 2003 *Gurus* Posted February 10, 2003 You'll have to do all those things yourself, by writing code to persist the number of boxes and their position (either to the registry or to an xml file, etc). Are you sure you really need to do things this way? Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted February 10, 2003 Author Posted February 10, 2003 How else could I do it the same way? Quote C#
*Gurus* divil Posted February 10, 2003 *Gurus* Posted February 10, 2003 I don't know. You need to give a broader description of your project and what it needs to do. It is unusual for a program to create textboxes on the fly and maintain them from one execution to the next. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted February 10, 2003 Author Posted February 10, 2003 Why do I always do unusual things?. . . Ms word seems to do it with the toolbar. Not textboxes but icons. Quote C#
*Gurus* divil Posted February 10, 2003 *Gurus* Posted February 10, 2003 Yes, and writing the logic to handle that is equally difficult :) Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted February 10, 2003 Author Posted February 10, 2003 They must be good. I hope to get there. I only have 50 trillion miles to go. Quote C#
aewarnick Posted February 10, 2003 Author Posted February 10, 2003 Would it be ok to just create a whole buch of text boxes (about 20) and just hide them. When the user wants more to go into design mode and drag them to where they want them? Quote C#
Leaders quwiltw Posted February 10, 2003 Leaders Posted February 10, 2003 I wouldn't want to maintain it. Why don't you do as divil suggested and provide some more details of the project and let someone help come up with a more appropriate UI design? Quote --tim
aewarnick Posted February 10, 2003 Author Posted February 10, 2003 I hope that goes through. I sent the whole project. I am making a log for my company to write details about people and about the house. I want to separate all the people from the house text boxes. And the people and house boxes can come and go.windowsapplication1.zip Quote C#
Leaders quwiltw Posted February 10, 2003 Leaders Posted February 10, 2003 It isn't clear what Textbox1 and textbox2 are for. Are they two separate log entries? What is button1 for on the new comm log input form? btw. having variable names the same as keywords, like your "New" is not so good. Quote --tim
aewarnick Posted February 10, 2003 Author Posted February 10, 2003 It is very unfinished. The form will initiallly have about 16 Text boxes on it (includes Rich). Only 2 of them (Text Box: persons name)(Rich text box: persons information) will be 1 person initially. But that will fluxuate when more than one person is at each house. That means I'll need to add textboxes at runtime. Ignore button1. I was just experimenting. I am thinking that I could just create a child window for the house info. So that would be 2 separate forms that could auto scroll. Quote C#
*Gurus* divil Posted February 10, 2003 *Gurus* Posted February 10, 2003 Why not use a control list a listbox or listview, which is meant for adding and removing items programmatically? Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted February 10, 2003 Author Posted February 10, 2003 That is not permanant enouph. It is rare that people will be leaving and rare that new boxes will need to be added but they will need to be addes eventually. The small boxes are for their names and they will stay the same each time the program is opened (they clear now, but they won't later). When a resident of the house dies or leaves their name will be removed along with the corrosponding Rich text box. But if a residnet comes to live there, 2 new boxes must be made. When the user enters in info on the residents for that day it saves to a text file names as the current date. On the first form it reads that file to display it to the users. Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.