动态按钮文本左对齐
Dynamic button text align to Left
我需要在 C# WinForms 应用程序中水平左对齐按钮的文本。所有按钮都是动态创建的。我尝试了以下几种方法。但是没用。
private void dynBtnClick(string btnText) //Dynamic Text List In flp2
{
string[] listData = File.ReadAllLines(filePath + @"\" + btnText + ".txt");
int e=listData.Count();
flp2.FlowDirection = FlowDirection.LeftToRight;
flp2.Controls.Clear();
for ( int j =0; j<e;j++)
{
Guna.UI2.WinForms.Guna2Button iBtn = new Guna.UI2.WinForms.Guna2Button();
iBtn.Tag = j;
iBtn.BorderRadius = 5;
iBtn.Height = 25;
iBtn.Width = 200;
iBtn.AutoSize = false;
iBtn.Animated = true;
iBtn.FillColor = ColorTranslator.FromHtml("#263238");
iBtn.TextAlign = ContentAlignment.MiddleLeft;
string[] btnFacetext = listData[j].Split('~');
iBtn.Text = btnFacetext[0].ToString();
iBtn.Click += (s, c) => { flp2Action(btnFacetext[0]+"~"+ btnFacetext[1], btnText); };
flp2.Controls.Add(iBtn);
}
}
不适合我。
iBtn.TextAlign = Left;
iBtn.TextAlign = ContentAlignment.MiddleLeft;
这是当前按钮状态(用红线标记)。需要文本左对齐。请帮忙解决这个问题。
Guna.UI2.WinForms.Guna2Button.TextAlign
是 HorizontalAlignment
类型而不是 ContentAlignment
iBtn.TextAlign = HorizontalAlignment.Left
;
我需要在 C# WinForms 应用程序中水平左对齐按钮的文本。所有按钮都是动态创建的。我尝试了以下几种方法。但是没用。
private void dynBtnClick(string btnText) //Dynamic Text List In flp2
{
string[] listData = File.ReadAllLines(filePath + @"\" + btnText + ".txt");
int e=listData.Count();
flp2.FlowDirection = FlowDirection.LeftToRight;
flp2.Controls.Clear();
for ( int j =0; j<e;j++)
{
Guna.UI2.WinForms.Guna2Button iBtn = new Guna.UI2.WinForms.Guna2Button();
iBtn.Tag = j;
iBtn.BorderRadius = 5;
iBtn.Height = 25;
iBtn.Width = 200;
iBtn.AutoSize = false;
iBtn.Animated = true;
iBtn.FillColor = ColorTranslator.FromHtml("#263238");
iBtn.TextAlign = ContentAlignment.MiddleLeft;
string[] btnFacetext = listData[j].Split('~');
iBtn.Text = btnFacetext[0].ToString();
iBtn.Click += (s, c) => { flp2Action(btnFacetext[0]+"~"+ btnFacetext[1], btnText); };
flp2.Controls.Add(iBtn);
}
}
不适合我。
iBtn.TextAlign = Left;
iBtn.TextAlign = ContentAlignment.MiddleLeft;
这是当前按钮状态(用红线标记)。需要文本左对齐。请帮忙解决这个问题。
Guna.UI2.WinForms.Guna2Button.TextAlign
是 HorizontalAlignment
类型而不是 ContentAlignment
iBtn.TextAlign = HorizontalAlignment.Left
;