Loading...
Loading...
Compare original and translation side by side
using Syncfusion.WinForms.Buttons;
using System.Windows.Forms;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// Create and configure SfButton
SfButton sfButton1 = new SfButton();
sfButton1.Text = "Click Me";
sfButton1.Font = new System.Drawing.Font("Segoe UI", 10F);
sfButton1.Location = new System.Drawing.Point(50, 50);
sfButton1.Size = new System.Drawing.Size(120, 40);
// Add click event
sfButton1.Click += SfButton1_Click;
// Add to form
this.Controls.Add(sfButton1);
}
private void SfButton1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Button clicked!");
}
}using Syncfusion.WinForms.Buttons;
using System.Windows.Forms;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// Create and configure SfButton
SfButton sfButton1 = new SfButton();
sfButton1.Text = "Click Me";
sfButton1.Font = new System.Drawing.Font("Segoe UI", 10F);
sfButton1.Location = new System.Drawing.Point(50, 50);
sfButton1.Size = new System.Drawing.Size(120, 40);
// Add click event
sfButton1.Click += SfButton1_Click;
// Add to form
this.Controls.Add(sfButton1);
}
private void SfButton1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Button clicked!");
}
}sfButton1.Text = "Save";
sfButton1.Image = Image.FromFile(@"save-icon.png");
sfButton1.TextImageRelation = TextImageRelation.ImageBeforeText;
sfButton1.ImageSize = new Size(20, 20);sfButton1.Text = "Save";
sfButton1.Image = Image.FromFile(@"save-icon.png");
sfButton1.TextImageRelation = TextImageRelation.ImageBeforeText;
sfButton1.ImageSize = new Size(20, 20);sfButton1.Text = ""; // Empty text
sfButton1.Image = Image.FromFile(@"icon.png");
sfButton1.ImageSize = new Size(24, 24);
sfButton1.Style.BackColor = Color.White;
sfButton1.Style.Border = null;sfButton1.Text = ""; // Empty text
sfButton1.Image = Image.FromFile(@"icon.png");
sfButton1.ImageSize = new Size(24, 24);
sfButton1.Style.BackColor = Color.White;
sfButton1.Style.Border = null;sfButton1.Style.BackColor = Color.LightBlue;
sfButton1.Style.ForeColor = Color.Black;
sfButton1.Style.HoverBackColor = Color.Blue;
sfButton1.Style.HoverForeColor = Color.White;
sfButton1.Style.PressedBackColor = Color.DarkBlue;
sfButton1.Style.PressedForeColor = Color.White;sfButton1.Style.BackColor = Color.LightBlue;
sfButton1.Style.ForeColor = Color.Black;
sfButton1.Style.HoverBackColor = Color.Blue;
sfButton1.Style.HoverForeColor = Color.White;
sfButton1.Style.PressedBackColor = Color.DarkBlue;
sfButton1.Style.PressedForeColor = Color.White;sfButton1.Text = "Variable Length Content";
sfButton1.AutoSize = true; // Auto-adjust to content
sfButton1.Font = new Font("Segoe UI", 11F);sfButton1.Text = "Variable Length Content";
sfButton1.AutoSize = true; // Auto-adjust to content
sfButton1.Font = new Font("Segoe UI", 11F);// In Program.cs Main():
SfSkinManager.LoadAssembly(typeof(Office2016Theme).Assembly);
// In form:
sfButton1.ThemeName = "Office2016Colorful";// In Program.cs Main():
SfSkinManager.LoadAssembly(typeof(Office2016Theme).Assembly);
// In form:
sfButton1.ThemeName = "Office2016Colorful";| Property | Type | Purpose |
|---|---|---|
| string | Button display text |
| Image | Button image/icon |
| Size | Dimensions of displayed image |
| TextImageRelation | Position of image relative to text |
| ContentAlignment | Text alignment within button |
| ContentAlignment | Image alignment within button |
| bool | Auto-fit button to content |
| bool | Enable text wrapping |
| bool | Show ellipsis for trimmed text |
| bool | Enable rich text formatting |
| Image | Background fill image |
| bool | Show focus indicator rectangle |
| string | Apply built-in theme |
| ButtonVisualStyle | Access appearance customization |
| 属性 | 类型 | 用途 |
|---|---|---|
| string | 按钮展示文本 |
| Image | 按钮图片/图标 |
| Size | 展示图片的尺寸 |
| TextImageRelation | 图片相对于文本的位置 |
| ContentAlignment | 按钮内文本对齐方式 |
| ContentAlignment | 按钮内图片对齐方式 |
| bool | 按钮自适应内容大小 |
| bool | 启用文本换行 |
| bool | 文本裁剪时显示省略号 |
| bool | 启用富文本格式化 |
| Image | 背景填充图片 |
| bool | 显示聚焦指示矩形 |
| string | 应用内置主题 |
| ButtonVisualStyle | 访问外观自定义配置 |
Syncfusion.Core.WinFormsSyncfusion.Shared.BaseSyncfusion.Office2016Theme.WinFormsSyncfusion.Core.WinFormsSyncfusion.Shared.BaseSyncfusion.Office2016Theme.WinForms