悬赏分:20 浏览:202 次
是这样的
我下了一个自定义button控件(椭圆形控件),但没换行功能,
所以想请教各位
先谢了
|
1个月前 右手年华 : TO 金鱼: 我做的是winfrom程序,没有</br>, 但你的思路可以借鉴一下,问题又来了我怎么让文本换行呢? |
|
1个月前 右手年华 : TO Colin Han: 我就是从网上找了个自定义的椭圆形按钮控件,但他不能换行, 所以想让文本换行,此控件是从UserControl继承来的 if( this.Text != null ) { // 绘制文本 using( StringFormat f = new StringFormat()) { // 水平居中对齐 f.Alignment = System.Drawing.StringAlignment.Center ; // 垂直居中对齐 f.LineAlignment = System.Drawing.StringAlignment.Center ; // 设置为单行文本 f.FormatFlags = System.Drawing.StringFormatFlags.NoWrap ; //f.FormatFlags = System.Drawing.StringFormatFlags.MeasureTrailingSpaces; // 绘制文本 using( SolidBrush b = new SolidBrush( this.ForeColor )) { e.Graphics.DrawString( this.Caption , this.Font , b , new System.Drawing.RectangleF( 0 , 0 , this.ClientSize.Width , this.ClientSize.Height ) , f ); } } 我感觉是// 设置为单行文本 f.FormatFlags = System.Drawing.StringFormatFlags.NoWrap ; 的问题,但是了半天也没试出来。 |