Solved

MessageBox like Popup with label?

Posted on 2006-07-08
5
221 Views
Last Modified: 2010-04-16
I found a nice EE article that works fine except I need a Label to appear on the newly created message form.

Link:     http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21752115.html?query=close+messagebox&topics=327

Code:  
            Form popup = new Form();
            popup.Text = "A popup form";
            popup.FormBorderStyle = FormBorderStyle.Sizable;
            popup.Size = new Size(200, 200);
            popup.Show();


Label:   Label label1 = new System.Windows.Forms.Label();
            label1.AutoSize = true;
            label1.Location = new System.Drawing.Point(57, 30);
            label1.Name = "label1";
            label1.Size = new System.Drawing.Size(35, 13);
            label1.TabIndex = 1;
            label1.Text = "label1";
            label1.Show();
0
Comment
Question by:kvnsdr
  • 2
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
CaldNT earned 250 total points
ID: 17068630
Try this code:


            // First create the form object
            Form popup = new Form();

            //Create the label and set it's properties
            Label label1 = new System.Windows.Forms.Label();
            label1.AutoSize = true;
            label1.Location = new System.Drawing.Point(57, 30);
            label1.Name = "label1";
            label1.Size = new System.Drawing.Size(35, 13);
            label1.TabIndex = 1;
            label1.Text = "label1";

            //Add the label to the form
            popup.Controls.Add(label1);

            //Set the form's properties            
            popup.Text = "A popup form";
            popup.FormBorderStyle = FormBorderStyle.Sizable;
            popup.Size = new Size(200, 200);

            //Show the form
            popup.Show();
0
 
LVL 4

Expert Comment

by:CaldNT
ID: 17068639
You can add any control in the same way.

The code is basically the same that would be generated by the VS IDE for a similar form. But this code is hidden in a Partial class in VS 2005.

Feel free to ask any other questions regarding the code.

Good luck,

Marcos
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17068984
0
 
LVL 1

Author Comment

by:kvnsdr
ID: 17070285
Yes, TheLearnedOne, I did but it's not C# code.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17070294
I am sorry, did you need your hand held?

Bob
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now