0
是否有可以打开或使用旋转标签90度的peramerter或设置?我想通过设计小组使用它。在Visual Studio中翻转设计面板中的标签
我想避免必须通过代码,如果可能的话。
即时通讯目前使用C#作为我的基地
是否有可以打开或使用旋转标签90度的peramerter或设置?我想通过设计小组使用它。在Visual Studio中翻转设计面板中的标签
我想避免必须通过代码,如果可能的话。
即时通讯目前使用C#作为我的基地
没有物业旋转文字90度。你需要编写自己的控件。
为您的项目添加一个新类并粘贴下面显示的代码。编译。将新的控件从工具箱的顶部拖放到表单上。注意低于恒星的渲染质量和测量字符串长度的正常麻烦。
using System;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
class VerticalLabel : Label {
private SizeF mSize;
public VerticalLabel() {
base.AutoSize = false;
}
[Browsable(false)]
public override bool AutoSize {
get { return false; }
set { base.AutoSize = false; }
}
public override string Text {
get { return base.Text; }
set { base.Text = value; calculateSize(); }
}
public override Font Font {
get { return base.Font; }
set { base.Font = value; calculateSize(); }
}
protected override void OnPaint(PaintEventArgs e) {
using (var br = new SolidBrush(this.ForeColor)) {
e.Graphics.RotateTransform(-90);
e.Graphics.DrawString(Text, Font, br, -mSize.Width, 0);
}
}
private void calculateSize() {
using (var gr = this.CreateGraphics()) {
mSize = gr.MeasureString(this.Text, this.Font);
this.Size = new Size((int)mSize.Height, (int)mSize.Width);
}
}
}
有许多不同的GUI技术可以在Visual Studio中进行布局,其中大部分都包含一个'Label'控件。祈祷告诉你,你指的是? – Jay 2010-09-10 14:27:01
我目前正在使用C#作为我的基础。 – 2010-09-10 14:41:11
Jay的意思是你用什么来创建GUI? WinForms,WPF,ASP.NET? – w69rdy 2010-09-10 14:46:40