Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i set a form title via a menu toolbox?

Status
Not open for further replies.

Mibble

IS-IT--Management
Sep 9, 2004
28
US
i would like to set the title of a windows form via a menu toolbar, where a menu says 'Change Title'. When clicked, it allows the title change with Aa thru Zz only (no numbers, etc). If no title, it defaults to welcome and the registry key for the title is deleted.
currently items working are:

key.SetValue("X", Location.X);
key.SetValue("Y", Location.Y);
key.SetValue("Height", Height);
key.SetValue("Width", Width);
key.SetValue("CurrColor", currColor.Name);
key.SetValue("Title", title);
//key.SetValue("LastFile");
Application.Exit();

which means i can write to the registry. however i can not get a valid title written or read back.
lastfile is another needed.

thanks
 
When user has choosen a new form title how are you saving it in the registry? post some code...
 
You're saving config options to the registry? Why wouldn't you just write it to some kind of user config file so you can port the config to other boxes easily if needed?
 
i am trying to figure out how to save the title to the registry. i am not wanting to use a config file, this is so i can learn how to read and write to the registry properly. the code above shows writing to the registry, which is going into hkey current user software dummy name dummy folder, so as not to overwrite anything else which i have not created.

this is what i have thus far, once a user selects the file menu, there is an option there which sets the title. i dont know how to make that open a text box, which in turn would use this portion of code for the registry:

private void setTitleToolStripMenuItem_Click(object sender, EventArgs e)
{
Form myForm = new Form();
myForm.Text =
this.title = "Write something there";
}

on exit whatever i have in this.title does get written to the registry.
 
an update on what i did, on the menu bar, where i have the option to 'Set Title' i added the option for what gets opened to a text box, which i have thus named 'txtTitleChange', which does allow me to change the title, i changed this.title = txtTitleChange.text however the left side is null, right side contains what i need.
no error, what have i done wrong here?
 
You can open the other form by doing this:

myForm.ShowDialogue();

What is in the above form? and why you need to use it?

Second part:
------------
What I understand is that "this.title" is still null when assignment has been done ....

In "this.title" ... what is the type of "this" ?
 
i have deleted the other form, it was not being utilized. this.title is of object type, i can write the title to the registry and read it back, however i can not place it in the title spot, just doesnt go.

if (txtTitleChange.Text != null)
{
this.title = txtTitleChange.Text;
}
else
{
this.title = "Welcome";
}

 
this.title" is of object type but what is the type of "THIS"?

a windows form does not have TITLE .... it has TEXT or CAPTION etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top