change button location in in C#

Sun Jan 04, 2009 12:00 pm

This simple code all you show to you how to change the place of your button on the forum,
by changing the line
Code:
   
mybutton.Location = new Point(50, 50);


Here the button will be set on the point 50,50 on your form .

Here the overview example
Code:


using System
;
using System.Drawing;
using System.Windows.Forms;
   
class 
newButtonForm
{
     public static 
void Main()
     {
          
Application.Run(new newButton());
     }
     public 
newButton()
     {
          
Text "Button";
   
          
Button mybutton   = new Button();
          
mybutton.Parent   this;
          
mybutton.Text     "Ok";
          
mybutton.Location = new Point(5050);
          
mybutton.Click   += new EventHandler(ButtonActionClick);
     }
     
void ButtonActionClick(object objEventArgs ea)
     {
          
Graphics grfx   CreateGraphics();
          
Point    placeText Point.Empty;
          
string   stringaction    "Clicked";
   
          
grfx.DrawString(stringactionFont, new SolidBrush(ForeColor), placeText);
          
grfx.Dispose();
     }
}

 




  Related Posts  to : change button location in in C#
 location of a package statement within a source code file     -  
 Test Lead (HealthCare BCBS Exp) / Location: Owings Mills     -  
 Convert link and button to custom button with good style     -  
 Gel Button     -  
 Strong tag with button tag     -  
 put image on button in C#     -  
 gel button in flash     -  
 create a web 2.0 button     -  
 disable button     -  
 create button in asp.net     -  

Topic Tags

C# Forms