Windows Develop Bookmark and Share   
 index > Windows Forms General > TextBox and c#
 

TextBox and c#

How to display a textBox in topleft,topright,center and random positions of the screen in c#?

How to change the opacity of the windows form using c# code?

WillfinDavid  Tuesday, February 14, 2006 2:31 PM

For topleft, topright and center use:


public void MoveToTopLeftCorner()
{
    txtBox.Left = 0;
    txtBox.Top = 0;
}
public void MoveToCenter()
{
    txtBox.Left = (txtBox.Parent.Width / 2) - (txtBox.Witdh);
    txtBox.Top = (txtBox.Parent.Height/ 2) - (txtBox.Height);
}

 


For random, place a Timer on you Form and in the Tick event of the timer place code that look like this:


private void timer1_Tick(object sender, System.EventArgs e)
{
    Random rnd = new Random();
    txtBox.Left = rnd.Next(0, Width - txtBox.Width);
    txtBox.Top = rnd.Next(0, Height - txtBox.Height);
}

 

For settings the opacity use the Opacity property of the Form class:


this.Opacity = 0.5;
 

Pieter Joost van de Sande  Tuesday, February 14, 2006 2:47 PM

For topleft, topright and center use:


public void MoveToTopLeftCorner()
{
    txtBox.Left = 0;
    txtBox.Top = 0;
}
public void MoveToCenter()
{
    txtBox.Left = (txtBox.Parent.Width / 2) - (txtBox.Witdh);
    txtBox.Top = (txtBox.Parent.Height/ 2) - (txtBox.Height);
}

 


For random, place a Timer on you Form and in the Tick event of the timer place code that look like this:


private void timer1_Tick(object sender, System.EventArgs e)
{
    Random rnd = new Random();
    txtBox.Left = rnd.Next(0, Width - txtBox.Width);
    txtBox.Top = rnd.Next(0, Height - txtBox.Height);
}

 

For settings the opacity use the Opacity property of the Form class:


this.Opacity = 0.5;
 

Pieter Joost van de Sande  Tuesday, February 14, 2006 2:47 PM

You can use google to search for other answers

Custom Search

More Threads

• How to get line by line text from textBox with Multliline option in Windows Application?
• Custom Control not updating
• BUG: MonthCalendar, anyway to stop it from updating itself?
• Shown event seen before Activated event.why?
• EventID 5000 .NET Runtime 2.0 Runtime error
• Changing Windows Xp CD Key
• Determine if a Form has been created...
• How to overlap a Picturebox?
• Mistake of atl.dll in windows 2000
• Change cursor type for ActiveX control