최근에 나는 win forms 응용 프로그램을위한 수직 진행 막대가 필요했습니다. 파생 된 클래스는 아래와 같습니다. 진행률 표시 줄에 텍스트를 추가해야합니다. 그것에 레이블은 transperancy 문제의 beacuse 작동하지 않습니다. 몇 가지 조사를 한 후에 뭔가를 발견했습니다. 그러나 문제는 진행률 표시 줄이 세로 인 경우 텍스트가 가로로 표시된다는 것입니다. 나는 그것도 수직으로 필요로한다. 어떻게해야합니까?.NET Winforms 세로 진행률 막대 텍스트
감사합니다.
public class VProgressBar : ProgressBar
{
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style |= 0x04;
if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6)
{
cp.ExStyle |= 0x02000000; // WS_EX_COMPOSITED
}
return cp;
}
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == 0x000F)
{
using (Graphics graphics = CreateGraphics())
using (SolidBrush brush = new SolidBrush(ForeColor))
{
SizeF textSize = graphics.MeasureString(Text, Font);
graphics.DrawString(Text, Font, brush, (Width - textSize.Width)/2, (Height - textSize.Height)/2);
}
}
}
[EditorBrowsable(EditorBrowsableState.Always)]
[Browsable(true)]
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
Refresh();
}
}
[EditorBrowsable(EditorBrowsableState.Always)]
[Browsable(true)]
public override Font Font
{
get
{
return base.Font;
}
set
{
base.Font = value;
Refresh();
}
}
}
이 질문에 대한 이전 답변을 참조하십시오 - http://stackoverflow.com/questions/1371943/c-sharp-vertical-label-in-a-winform을 – ChrisF