Jay1b Posted September 18, 2003 Posted September 18, 2003 I am trying to create a picture by code, by copying some of the stuff out of the form designer i have come up with. Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim PicBox_1_2 As New PictureBox ' Dim PicBox_1_3 As New PictureBox ' 'PicBox_1_2 ' PicBox_1_2.Location = New System.Drawing.Point(80, 84) PicBox_1_2.Name = "PicBox_1_2" PicBox_1_2.Size = New System.Drawing.Size(100, 92) PicBox_1_2.TabIndex = 0 PicBox_1_2.TabStop = False PicBox_1_2.BackColor = Color.Red End Sub But it doesnt show. have i missed something? Quote
*Experts* mutant Posted September 18, 2003 *Experts* Posted September 18, 2003 You need to add it to the control collection of the form: FormObject.Controls.Add(PicBox_1_2) Quote
Jay1b Posted September 18, 2003 Author Posted September 18, 2003 (edited) That was prompt. :) Thank you Edited September 18, 2003 by Jay1b Quote
Drstein99 Posted October 3, 2003 Posted October 3, 2003 I have a simular problem, and read this thread - the answer helped me half-way. I have a question to addend to the original question. When I add the object to the control of the form, on the form there is a group box. I want to put the object in the group-box. If I add it to the form, it's putting behind the group box. If I add to the group box like this: mForm.groupbox1.Controls.Add(textBoxCustom) It always puts it in the title of the group box, no matter if i change the position of the textbox. Any ideas? Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
*Experts* mutant Posted October 3, 2003 *Experts* Posted October 3, 2003 If im understanding right what you mean by saying it puts it in the title, then I dont have that problem, it works all right for me. What code are you using the create the TextBox? Quote
Drstein99 Posted October 3, 2003 Posted October 3, 2003 I figured it out. Here is the code: Dim tb1 As New TextBox tb1.Location = New Point(15, 15) 'this line of code tb1.Visible = True tb1.Text = "TEST INFORMATION" tb1.ForeColor = Color.RosyBrown tb1.BorderStyle = BorderStyle.None 'tb1.Location.X.Equals(22) 'tb1.Location.Y.Equals(22) tb1.Size.Height.Equals(15) tb1.Size.Width.Equals(280) mFormScript.rtScript.Controls.Add(tb1) Where "this line of code" is where I needed to add. Was using "tb1.location.x.equals(22)" - with no results. Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
SourceCoders Posted October 3, 2003 Posted October 3, 2003 You must add your textbox to the groupbox an not to the form --> groupboxname.Controls.Add(textboxname) groupboxname -> Name of your groupbox textboxname -> Name of your textbox Quote
Drstein99 Posted October 3, 2003 Posted October 3, 2003 Yep. I figured that much out. Thanks for the help Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Drstein99 Posted October 3, 2003 Posted October 3, 2003 Ok while we're on the same page I got another question around the same topic. I want to create a textbox and add to the richtextedit (which was done - i.e.: earlier posts) when i do: dim tb as new textbox and then: mFormScript.rtScript.Controls.Add(tb1) I want to be able to make the name of the object from a string, like pass the function a parameter: private sub createnewtextbox(byval prmInString as string) dim prmInString as newtextbox mFormScript.rtScript.Controls.Add(prmInString) how do i do this? Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
SourceCoders Posted October 3, 2003 Posted October 3, 2003 One moment please, about 5-10 minutes..... :) Quote
SourceCoders Posted October 3, 2003 Posted October 3, 2003 It´s very funny... At the moment I´m writting a application for a printing company and the same problem makes me sad since a few weeks. It is not possible to solve this!!!! I have in many many forums asked this question, last at microsoft ..... no answer. SORRY !! My problem have i solved in a other way, when you describe your´s more exactly maybe I can help you... Let us communicate further in this post, I´m the whole online (programming...... :-) ) Quote
Drstein99 Posted October 6, 2003 Posted October 6, 2003 I'm writing a data-capture application. It uses a rich text box to populate from a memo field in a msaccess table (currently) The information is displayed on the screen read-only mode. Simular to filling out a job application I.E.: What is your first name **overlapping textbox goes here** have you ever been married **next overlapping textobx ** The pages will vary at random with a different list of questions to be answered. Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
*Experts* Bucky Posted October 6, 2003 *Experts* Posted October 6, 2003 Drstein, I see where your problem lies. 'tb1.Location.X.Equals(22) 'tb1.Location.Y.Equals(22) tb1.Size.Height.Equals(15) tb1.Size.Width.Equals(280) I see that the first two lines are commented out, but you made the same mistake for all four. The Equals method that all types have is a function that returns a boolean value telling whether the value passed to it is equal to the object itself. It is not a setter function such as you might have in a property declaration. It is just a function that returns a value. Your code will work correctly if you use the = operator like so: tb1.Location.X = 22 tb1.Location.Y = 22 tb1.Size.Height = 15 tb1.Size.Width = 280 Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Drstein99 Posted October 6, 2003 Posted October 6, 2003 Bucky, I see where you have corrected A problem in my code. Thanks. Unfortunately, thats not the nature of the issue. Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Drstein99 Posted October 7, 2003 Posted October 7, 2003 When I do: tb1.Size.Height = 15 the error I get is: "expression is a value and therefore cannot be a target of an assignment" Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Drstein99 Posted October 7, 2003 Posted October 7, 2003 Also - after I new the object and add to the control list how do i dispose it, or access it later? Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
*Experts* Bucky Posted October 7, 2003 *Experts* Posted October 7, 2003 For setting the size and location, use the constructor of the Point and Size structures: tb1.Location = New Point(22, 22) tb1.Size = New Size(280, 15) As for accessing the control later, store it in a form-level variable that you can change properties of and such, or remove from the Controls collection when you want to remove it. ' This is in general declarations: Dim myControl As TextBox ' Then, when you want to init it: myControl = New TextBox() ' Set the properties here Me.Controls.Add(myControl) ' And to dispose of it: Me.Controls.Remove(myControl) myControl.Dispose() myControl = Nothing Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
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.