473,386 Members | 1,763 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,386 software developers and data experts.

Windows Forms: Open SettingsWindow (popup)

I'm trying to play a little bit with Windows Forms, to make a little application.

But here's how I'd like it to be:

I've made a little link named "SettingsLink" (file is named SettingsWindow.cs" (Type: LabelLink).
The text on the link is "Settings".

How can I make the window popup?
I've tried several things, but nothing has helped so far.

Current code from the link:

Expand|Select|Wrap|Line Numbers
  1.             // SettingsLink
  2.             // 
  3.             this.SettingsLink.AutoSize = true;
  4.             this.SettingsLink.Location = new System.Drawing.Point(1066, 85);
  5.             this.SettingsLink.Name = "SettingsLink";
  6.             this.SettingsLink.Size = new System.Drawing.Size(45, 13);
  7.             this.SettingsLink.TabIndex = 2;
  8.             this.SettingsLink.TabStop = true;
  9.             this.SettingsLink.Text = "Settings";
  10.  
Sep 21 '10 #1
7 2877
Airslash
221 100+
Assign the onClick event handler for your label. In the event, create & show the settings window.

When the user closes the window, you update the mainform with the settings applied in the SettingsWindows.

I think the easiest way of doing this, is by showing the SettingsWindow as a Modal form on your main windows when clicking the link and then extracting the data you need from the settings form.

From the top of my head:

Expand|Select|Wrap|Line Numbers
  1. // Add this
  2. this.SettingsLink.OnClick += new EventHandler<EventArgs>(new_func_name);
  3.  
  4. // create the event function
  5. void new_func_name(object sender, EventArgs e)
  6. {
  7.       SettingsForm form = new SettingsForm();
  8.       if(SettingsForm.ShowModel() == ModalResponse.OK)
  9.       {
  10.              // DO stuff with settings
  11.       }
  12. }
  13.  
This is sort of the code you're looking for. I think it should be fairly easy to find sufficient examples about using forms as Modal Forms.
Sep 21 '10 #2
Well.
Just by watching the code You posted (I'm PHP developer), then it doesn't seem to be what I've been looking for, but I'll give it a try later (I'm in school right now).

But as said, all I want it to do, is to pop up the window, like if You selected "Tools" > "Settings" in either Internet Explorer or Firefox.

In that window, I'll make some content etc.
Sep 21 '10 #3
Airslash
221 100+
Ah you should have told that from the start.
So if I understand your question correctly, you have a small application, created in Windows Forms, and you wish to open a browser to a specific URL that will show you a page with settings?

If that's the case, you require still the onClick event for the linkLabel, but instead of that form code, you need to inform windows to open the default browser and redirect it to the specific URL you wish to display.

I'm not 100% sure if this is actually safe to perform, or if there is a better way of doing this, but if you pass the URL directly into the WindowsShell, it should open the default browser to that address:

Expand|Select|Wrap|Line Numbers
  1. // Assign the eventhandler for the onClick event.
  2. this.SettingsLink.OnClick += new EventHandler<EventArgs>(link_onClick);
  3.  
  4. // This is the function that will be raised
  5. void link_onClick(object sender, EventArgs e)
  6. {
  7.     // Open the default browser and point to your URL      System.Diagnostics.Process.Start("http://www.google.com");
  8. }
  9.  
I think this should do the trick, but I don't guarantee it to be safe or working 100%.
Sep 21 '10 #4
It wasn't what I've been looking for (but it was helpful anyways!).
I also needed a way to link to my website, and this helped me.

Look.
This is how I want it to be.
Let's take WLM/MSN Messenger as example.
What I need is something like "Tools" > "Options..."

I want to create such window.
Sep 22 '10 #5
Airslash
221 100+
then you require what I wrote in my first post normally. A second form in your application that represents the configuration form, which gets called by the onClick event of the linklabel you have on the mainform.

When you show the configuration form as a ModalForm (google it), you prevent the user from performing actions on the mainform untill he has closed the configuration form, just like MSN messenger does.

By using delegates (callback functions) you can trigger actions in the mainform by doing stuff on the configuration form.
Sep 22 '10 #6
The first post You wrote, just came up with tons of red lines (functions not defined)...

I will take a look at it later, the project has been postponed atm.
Sep 22 '10 #7
Airslash
221 100+
You'll need to find the correct declarations ofcourse. The code posted was mearly a guideline to get you on the right track and the terms you'll need to look up.
Sep 23 '10 #8

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

Similar topics

4
by: @(none) | last post by:
Hi, I have a picturegallery that opens in a new window as a defined size, but I would like to open the popup in the middle of the screen. Some browsers do it like that, others don't... Any ideas...
1
by: Paul Sampson | last post by:
There is probably a simple answer to this one. I've come from a VB6 background, where I've used the Open event on a form to load data structures, bind controls, etc. Unless I'm overlooking the...
6
by: Ayende Rahien | last post by:
Excetremely annoying problem, I've an application with a long startup time. So I created another form with my logo in it to as a splash screen. The splash screen is run from another thread and is...
2
by: fperfect13 | last post by:
Hi, I have the folowing exception Exception : System.NullReferenceException: Object reference not set to an instance of an object. 00000019 3:30:48 PM at...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
0
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
2
by: Shane Story | last post by:
Is there a way, using a browser such as Internet Explorer, to allow a user to, access some link, and it maybe download/open a copy of a full blown fat client Windows Forms .NET application and run...
0
by: ABC | last post by:
How to share forms authentication with popup windows? As the main page is completed logon. My pages have some popup windows to lookup or select from list items. But all popups windows will...
21
by: Dan Tallent | last post by:
In my application I have a form (Customer) that I want to be able to open multiple copies at once. Within this form I have other forms that can be opened. Example: ZipCode. When the user enters...
2
by: harvindersingh | last post by:
Hello guys, I am developing a Windows Forms application in C#, I am using PostgreSQL as the Database. The application is bassically using the database to store and lookup information, nothing so...
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.