Button Text Alignment : Button « GUI Windows Forms « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / CSharp Tutorial » GUI Windows Forms » Button 
23.8.14.Button Text Alignment
Button Text Alignment
using System;
using System.Drawing;
using System.Windows.Forms;

public class ButtonTextAlign : Form
{
  Button btn;

  public ButtonTextAlign()
  {
        Text = "Button Properties";
    Size = new Size(300,200);

    btn = new Button();
    btn.Parent = this;
    btn.Text = "text";
    btn.Location = new Point(10,10);

    btn.BackColor = Color.LightGreen;


    btn.TextAlign = ContentAlignment.MiddleLeft;
    
    f(btn);

  }

  static void Main() 
  {
    Application.Run(new ButtonTextAlign());
  }

  private void f(Button btn)
  {
    int xSize = 100;
    int ySize = 100;
    btn.Size = new Size(xSize, ySize);
  }
}
23.8.Button
23.8.1.Add a Button
23.8.2.Handle button messages
23.8.3.Relocate button after pressing button
23.8.4.Add Image in an ImageList to a ButtonAdd Image in an ImageList to a Button
23.8.5.Use delegate to add an event handler to a ButtonUse delegate to add an event handler to a Button
23.8.6.Button mouse eventButton mouse event
23.8.7.Set Label text in a button click eventSet Label text in a button click event
23.8.8.Add action handler to buttonAdd action handler to button
23.8.9.Button Style: image button, standard buttonButton Style: image button, standard button
23.8.10.Button PerformClick MethodButton PerformClick Method
23.8.11.Button Flat StyleButton Flat Style
23.8.12.Calculate Button size based on its TextCalculate Button size based on its Text
23.8.13.Button Background ColorButton Background Color
23.8.14.Button Text AlignmentButton Text Alignment
23.8.15.Button ImageButton Image
23.8.16.Auto Scale Button
23.8.17.extends Button
23.8.18.Device Independent Button
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.