473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

C#-APP: Groupbox naming issue. Simple problem

Hi guys,

I have a simple problem which i cant seem to figure out. Im not sure if its my fault, or just VS2008.. I have a group box, which i change its name to show a user that the contents of the group box have changed. It works fine the very first time i do this.

But after i close the form, and then create a new instance of the form, the group box no longer allows me to change the name. Or it DOES change the name, however the drawing of the name does not occur. I have tried to invalidate it, but it didnt work.

This is a totally new form, i dont know why this isnt a simple fix.. I also tried disposing it, but that makes it not able to be opened later for some reason.

Cheers
Gunsligner
Sep 30 '08 #1
6 1847
PRR
750 Expert 512MB
could you post some code? you just wanna change the text right?

Expand|Select|Wrap|Line Numbers
  1. Button b = new Button();
  2.             b.Location = new Point(50,300);
  3.             groupBox1.Controls.Add(b);         
  4.  
  5.             groupBox1.Text = "PRR";
  6.  
Sep 30 '08 #2
hmm, there isnt really much code to post.

As you said, its really just changing the .Text property. However, the odd thing is, i have two methods which do something else in the program, but at the end they both call a method which changes the groups name, but only one of these is actually successful. I cant see any errors in my code.

The question i really want an answer to now, is how to make sure that when i do a form.close() and then open a form by doing something like

form openForm = new (myFormType)
openForm.Show()

that it will actually be a totally new instance.

Sometimes i leave text on the form i want to close, and when i open it again, the text is still there, so it REALLY isnt a new form!
Sep 30 '08 #3
PRR
750 Expert 512MB
hmm, there isnt really much code to post.

As you said, its really just changing the .Text property. However, the odd thing is, i have two methods which do something else in the program, but at the end they both call a method which changes the groups name, but only one of these is actually successful. I cant see any errors in my code.

The question i really want an answer to now, is how to make sure that when i do a form.close() and then open a form by doing something like

form openForm = new (myFormType)
openForm.Show()

that it will actually be a totally new instance.

Sometimes i leave text on the form i want to close, and when i open it again, the text is still there, so it REALLY isnt a new form!
can you post some code?
"call a method which changes the groups name"
maybe you should call this first ...i mean the function that changes the name...
Expand|Select|Wrap|Line Numbers
  1. private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             //cal1();
  4.  
  5.             //Read12();
  6.             Button myByte = new Button();
  7.             myByte.Location = new Point(50, 300);
  8.  
  9.             groupBox1.Controls.Add(myByte);
  10.             groupBox1.Text = "PRR";
  11.  
  12.             Form1 my = new Form1();
  13.             my.Show();
  14.  
  15.         }
  16.  
Sep 30 '08 #4
tlhintoq
3,525 Expert 2GB
can you post some code?
"call a method which changes the groups name"
maybe you should call this first ...i mean the function that changes the name...
Expand|Select|Wrap|Line Numbers
  1. private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             //cal1();
  4.  
  5.             //Read12();
  6.             Button myByte = new Button();
  7.             myByte.Location = new Point(50, 300);
  8.  
  9.             groupBox1.Controls.Add(myByte);
  10.             groupBox1.Text = "PRR";
  11.  
  12.             Form1 my = new Form1();
  13.             my.Show();
  14.  
  15.         }
  16.  
Sometimes i leave text on the form i want to close, and when i open it again, the text is still there, so it REALLY isnt a new form!
I so want to see that. But I'd be happy to see the code where you are closing the form. Are you sure you are using .Close() and not .Hide() ?

Also.... In this code you create a button, then a GroupBox, add the button to the GroupBox, then make a new form.

At what point do you add the groupbox to the new form? To me it looks like the button lives in the groupbox, but the groupbox is homeless. Of is groupBox1 a GroupBox on the parent form that is creating the new Form1 named 'my'?

Without seeing the constructor code for your custom Form1 its hard to say why you continue to see the same text. Maybe the form reads data from the registry or an INI file you created, upon the creation of hte form? Is there a method that gets called that fills the form controls, possibly from global variables?

Sometimes methods get called by events we don't even know are being fired during the creation of a form. SizeChange for example. I've been stung by that one during creation since the form does change size but I only saw it in my mind as a user changing it after creation. If you have formatting methods triggered by text changing, size changing, parent changed and so on its possible the data is being read back into the form before you ever see it on screen. Maybe an automatic Load/Save method triggered by text changes?
Oct 1 '08 #5
PRR
750 Expert 512MB
I so want to see that. But I'd be happy to see the code where you are closing the form. Are you sure you are using .Close() and not .Hide() ?
// Comments
Actually i ditn close the form... just created new one .....abt the form hiding or closing.... i too had a lil prob in one of my project... if i remember correctly i had used static form objects and intialized them.. Closing the parent form is not the solution... You could create a few static objects of form and use them as needed...

Also.... In this code you create a button, then a GroupBox, add the button to the GroupBox, then make a new form.

At what point do you add the groupbox to the new form? To me it looks like the button lives in the groupbox, but the groupbox is homeless. Of is groupBox1 a GroupBox on the parent form that is creating the new Form1 named 'my'?

// Comments
gropubox is created right in the beginning....

Without seeing the constructor code for your custom Form1 its hard to say why you continue to see the same text. Maybe the form reads data from the registry or an INI file you created, upon the creation of hte form? Is there a method that gets called that fills the form controls, possibly from global variables?

// Comments
// in case.. you want the same form created... you can create another object and change the text n other things.. n then call show...

Sometimes methods get called by events we don't even know are being fired during the creation of a form. SizeChange for example. I've been stung by that one during creation since the form does change size but I only saw it in my mind as a user changing it after creation. If you have formatting methods triggered by text changing, size changing, parent changed and so on its possible the data is being read back into the form before you ever see it on screen. Maybe an automatic Load/Save method triggered by text changes?
Expand|Select|Wrap|Line Numbers
  1. public static Form1 parent;
  2.  
  3. //in button click
  4.  
  5. Button myByte = new Button();
  6.             myByte.Location = new Point(50, 300);
  7.  
  8.             groupBox1.Controls.Add(myByte);
  9.             groupBox1.Text = "PRR";
  10.  
  11.  
  12.  
  13.             Form1 my = new Form1();
  14.             my.button1.Text = "Something Else";
  15.             my.groupBox1.Text = "NEW";
  16.             my.Show();
  17.  
  18.             parent = this;
  19.             parent.Hide();
  20.  
  21.  
i guess you may have to look into parent child forms... i dont think you can close the parent form.. or the first form object... you could hide it though ...
Oct 1 '08 #6
PRR
750 Expert 512MB
let me see if i got you correctly:
1. you create a form...
2 .. on click of button or other events .. you want to create a new object of same form.. change the name of some buttons etc.. and show the changed stuff?
well if thats the case then you could do one thing ....
Expand|Select|Wrap|Line Numbers
  1. Form1 my = new Form1();
  2.             my = this;
  3.            // you will get all the stuff of main form...
  4.             my.button1.Text = "Something Else";
  5.             my.groupBox1.Text = "NEW";
  6.             my.Show();
  7.  
3. you need not close or hide the parent form if you could do the above...
4 . Incase you want to have separate forms... i suggest that you have some
public static objects of main form....

so did i understood wat u were tryin to say>? Do explain further... n post some code....
Oct 1 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Nick | last post by:
excuse me!! may i ask a simple problem here? if i dynamically allocate a memory(ex. new in C++ or malloc in C) in a sub-function and forget free the space end of the sub-function. does it...
1
by: newbie001 | last post by:
I have the following code in a listview control's initList function (called from form_load event). i can't understand why the listview box still appears blank with no columns or listview items. ...
3
by: Mark Allison | last post by:
Hi, VERY simple problem! if (regServer.UseTrustedConnection == 1) { string connectionString = "server=" + regServer.Name + "; Trusted_Connection=yes; database=master"; } else
18
by: Sender | last post by:
Yesterday there was a very long thread on this query. (You can search on this by post by 'sender' with subject 'Simple Problem' post date Oct 7 time 1:43p) And in the end the following code was...
12
by: Peter Proost | last post by:
Hi group, I've got what seems a simple problem, but I can't find the solution. I've got a textbox and a handheld scanner to scan barcodes, the scanner just generates keypresses like a keyboard...
2
by: Simon Harvey | last post by:
Hi everyone, I'm having a really simple problem - I can't seem to insert a null value into the database. When I do it tells me that the procedure expects the parameter and that I'm not providing...
4
by: R.A.M. | last post by:
Hi I have very simple problem - I need to process asp:Button click at server. I have written (my experience is little) in .aspx: <asp:Button ID="GoTo" runat="server" Text="Go To"...
8
by: rdrink | last post by:
I am just getting into pysqlite (with a fair amount of Python and MySQL experience behind me) and have coded a simple test case to try to get the hang of things... yet have run into a 'stock...
7
by: axlq | last post by:
I know this is a simple problem but it bedevils me. I'd like to have a container with two columns with the following properties: 1. Both columns dynamically adjust their width to fit their...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.