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

UserControl center sceen?

122 100+
I am sure this is real simple, I have a user control, not a form and I want t star it up in center screen, but there is no start position property.

Could someone provide some example or C# code to make this happen.

Thanks in advance.
Sep 11 '08 #1
10 7312
DragonLord
122 100+
Help please? Anyone?
Sep 12 '08 #2
Curtis Rutland
3,256 Expert 2GB
wrap it in <center> tags?
Sep 12 '08 #3
DragonLord
122 100+
I guess I am not being clear so let me clarify.

I created a custom login control in C# work awsome however the control does not have a startposition property so when the custom form loads it is to the upper left of the screen. I would like it to start in the center of the screen.

I am not sure how to do this and would appreciate any help, thanks.
Sep 12 '08 #4
You can not show the user control in stand-alone mode with form options because it is a control. In order to add a form behaviour you need a from object
that will "host" your control.
Sep 12 '08 #5
Frinavale
9,735 Expert Mod 8TB
Did you create a Web User Control or a desktop User Control?
Sep 12 '08 #6
Frinavale
9,735 Expert Mod 8TB
wrap it in <center> tags?
Sadly, the <center> tag is considered obsolete :(
To center a control now you'll have to place it in a <div> or Panel (which renders as a <div>) and set it's style to be style="margin-left:auto; margin-right:auto; width=50%" (note that you have to set the width).

This will center it horizontally but not vertically.
You'll have to use JavaScript to center it vertically.

You can center Text though by setting the line-height style for the <div> to be the same as the height of the <div>. One warning: if you have multiple lines of text this will not work.

I'm very disappointed that the <center> tag has become obsolete and am eagerly waiting for the day when CSS can achieve what the <center> tag used to.

-Frinny
Sep 12 '08 #7
DragonLord
122 100+
It is a desktop control
Sep 12 '08 #8
Frinavale
9,735 Expert Mod 8TB
It is a desktop control
Use the Location property of the control to set it to the middle.

eg:

Expand|Select|Wrap|Line Numbers
  1. myControl.Location= New Point(me.Width/2-myControl.Width/2, me.Height/2)
  2.  
Sep 12 '08 #9
DragonLord
122 100+
thanks, Frinavale that worked, but for those that want to know I figured out an easier way..

simply add:

Expand|Select|Wrap|Line Numbers
  1. public FormStartPosition StartPosition {get; set;}
  2.  
This will give you the functionality for the StartPosition property and it is simple as saying...

this.StartPosition = FormStartPosition.CenterScreen;

When you instantiate the control.
Sep 20 '08 #10
zubair1
79
Ooops (doh)

sorry didn't read the entire post first :)

disregard this post please :)
Sep 20 '08 #11

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

Similar topics

7
by: TT (Tom Tempelaere) | last post by:
Hi everyone, I'm developing a custom control that basically draws a circle. However I notice that when I resize a form that contains the control, there is a lot of flicker. I suppose that is...
2
by: bill yeager | last post by:
When trying to run my web project, I get the following error: Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the...
1
by: Patrick | last post by:
Problem I have an ASPX file, with a table of 3 columns, 2 rows with a usercontrol in the middle column (in the code snippet stated below, although in reality, the left hand column would also...
2
by: Fabiano | last post by:
Please, i have a ASPX that contains two usercontrols, TOP.ASCX and CENTER.ASCX. The first one has a dropdown list inside of it and the second one has a Datalist. When user changes the...
0
by: Patrick.O.Ige | last post by:
The SignOut() button below doesn't fire if in a UserControl but if i move it to an ASPX page it fires.. It seems i can't get access to the SUB in the USERCONTROL. Am i missing something? Any...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
3
by: Lee Moore | last post by:
I have some user controls defined that represent a common header and footer for a particular site. the footer contains links with querystring parameters based on session variables. The problem is,...
2
by: gerry | last post by:
based on MSPress's ASP.NET 2.0 Applications Advaced Topics ( Table 12-3 p.472 ), and most events should be automatically wired up when @Control AutoEventWireup="true". ie. Page_InitComplete() {}...
2
by: boomcreation | last post by:
Hi, When I load a userControl, I check if I have a variable session. If my variableSession1 = "A" and do nothing. but if my variableSession1 = "B", I want clear the html in my control and...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.