aewarnick Posted February 12, 2003 Posted February 12, 2003 I have text boxes that are small, but when clicked they will resize to large. The button is created and then I need the button to resize them back to where they were but I cannot reference the button anywhere except where I declared it. ooo.Dispose() does not compile because of that, Help. private void richTextBox1_Enter(object sender, System.EventArgs e) { this.richTextBox1.BringToFront(); this.richTextBox1.Size = new System.Drawing.Size(496, 300); Control r=new Button(); r.Font = new System.Drawing.Font("Verdana", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); r.Location = new System.Drawing.Point(richTextBox1.Location.X-35, richTextBox1.Location.Y); r.Name = "ooo"; r.Size = new System.Drawing.Size(35, 20); r.TabIndex = 1; r.Text = "Exit"; Controls.Add(r); r.BringToFront(); r.Show(); } private void ooo_Click(object sender, System.EventArgs e) { this.richTextBox1.Size = new System.Drawing.Size(496, 48); ooo.Dispose(); } Quote C#
Heiko Posted February 12, 2003 Posted February 12, 2003 I'd rather program an extendedRichBox Control, which inherits rich text box and has (a) the richttextbox (b) a resizeButton © a boolean property "shrinked" or so. Quote .nerd
Heiko Posted February 12, 2003 Posted February 12, 2003 if you insist on creating a new contol i suggest the following: private BigBox_Clicked(object sender, System.EventArgs e) { perform the shrinking here } } and private void richTextBox1_Enter(object sender, System.EventArgs e) { this.richTextBox1.BringToFront(); this.richTextBox1.Size = new System.Drawing.Size(496, 300); Control r=new Button(); r.Font = new System.Drawing.Font("Verdana", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); r.Location = new System.Drawing.Point(richTextBox1.Location.X-35, richTextBox1.Location.Y); r.Name = "ooo"; r.Size = new System.Drawing.Size(35, 20); r.TabIndex = 1; r.Text = "Exit"; Controls.Add(r); r.BringToFront(); r.Show(); AddHandler r.Click, AddressOf Me.BigBox_Clicked } Quote .nerd
aewarnick Posted February 12, 2003 Author Posted February 12, 2003 Are you saying that I can convert my boxes to extended types? I will try both, but I still cannot reference the button to delete it from the event handler. Quote C#
Heiko Posted February 12, 2003 Posted February 12, 2003 Sure. At compile time there simply is no object "ooo". Quote .nerd
aewarnick Posted February 12, 2003 Author Posted February 12, 2003 So I cannot use the button and then get rid of it? 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.