| 发表于:2007-12-27 08:47:03 楼主 |
button按扭初始问题 using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.text; using system.windows.forms; namespace windowsapplication6 { public partial class form1 : form { public form1() { initializecomponent(); } private void button1_paint(object sender, system.windows.forms.painteventargs e) { //初始化一个graphicspath类的对象 system.drawing.drawing2d.graphicspath mygraphicspath = new system.drawing.drawing2d.graphicspath(); //确定一个字符串,该字符串就是控件的形状 string stringtext = "arial"; //确定字符串的字体 fontfamily family = new fontfamily(stringtext); //确定字符串的风格 int fontstyle = (int)fontstyle.bold; //确定字符串的高度 int emsize = 35; //确定字符串的起始位置,它是从控件开始计算而非窗体 pointf origin = new pointf(0, 0); //一个stringformat对象来确定字符串的字间距以及对齐方式 stringformat format = new stringformat(stringformat.genericdefault); //用addstring方法创建字符串 mygraphicspath.addstring(stringtext, family, fontstyle, emsize, origin, format); //将控件的region属性设置为上面创建的graphicspath对象 custombutton.region = new region(mygraphicspath); } private void button1_click(object sender, eventargs e) { } } } 上面的代码是初始按扭的造型 为什么运行时候显示不出 如果把button1_paint代码放在button1_click下,然后运行点击可以看到效果 但这不是我想要的结果 我想一开始能看到彩色无筐字体的按扭,到底哪不对???? |
|
|
|
|