日期:2014-05-17 浏览次数:20770 次
Graphics g = e.Graphics; Pen pen = new Pen(Color.Red, 2.0f); foreach (Control ctr in this.Controls) { if (ctr is TextBox) { g.DrawRectangle(pen, new Rectangle(ctr.Location, ctr.Size)); } } //以上正常,在当前窗体里面的TextBox控件加了边框 foreach (Control ctr1 in this.Controls) { TabControl tab = ctr1 as TabControl; if (tab != null) { foreach (TabPage tp in tab.TabPages) { foreach (Control c in tp.Controls) { if (c is TextBox) { //这里设置边框不行 g.DrawRectangle(pen, new Rectangle(c.Location, c.Size)); c.Text = "abc";//这里有效,证明c已经找到了TextBox控件 //这里为什么没有BorderStyle这个属性呢? // c.BorderStyle = System.Windows.Forms.BorderStyle.None; } } } } } pen.Dispose(); }
/// <summary> /// CFlatTextBox:浮动文本框 /// </summary> [ToolboxBitmap (typeof(FlatTextBox), "FlatBox.bmp")] public class FlatTextBox : System.Windows.Forms.TextBox