日期:2014-05-19  浏览次数:21168 次

如何重绘statusbar和toolbar的颜色。。??散100分
问过这个问题。没人回答。可能是上次分数太少吧。。再次开帖子问。这次散100分,帮顶有分。
statusBar和toolbar没有backColor属性。如何改变它的颜色??
我做了一个自定义的控件。从statusbar继承。override   onpaint()函数,来重绘控件。但是发现根本程序就走不到这里。不知道为什么。
那位知道。麻烦告诉一声。谢谢了

------解决方案--------------------
http://www.99inf.net/article/netjc/others/2005-05-24/23936.html
------解决方案--------------------
DING
------解决方案--------------------
接分快乐。我最喜欢这么痛快的楼主。顺便将解决办法也贴出来。
------解决方案--------------------
drawItems是将控件的每个子项重画吧,类似于ListBox的DrawItem事件,不知是否?
------解决方案--------------------
还是2003的吧...

2005中没这个东东了,,改名了.
------解决方案--------------------
不会 mark
------解决方案--------------------
mark

------解决方案--------------------
JF~
------解决方案--------------------
this.statusBar1.DrawItem += new System.Windows.Forms.StatusBarDrawItemEventHandler(this.statusBar1_DrawItem);

private void statusBar1_DrawItem(object sender, System.Windows.Forms.StatusBarDrawItemEventArgs e)
{
Rectangle rc = new Rectangle(e.Bounds.X ,
e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);

StatusBar statusbarpanels = (StatusBar) sender;

Font aFont = new Font( "Microsoft Sans Serif ", (float)8.25,
FontStyle.Regular, GraphicsUnit.Point);
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Near;

e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(199, 216, 236)) , rc);
rc.Y+=3;
e.Graphics.DrawString(e.Panel.Text, aFont ,
new SolidBrush(Color.Black), rc ,sf);
rc.Y-=3;
rc.Height--;
rc.Width--;
e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(10,47,115))), rc );
rc.Height++;
rc.Width++;

e.DrawFocusRectangle();
}


再在设计中把this.statusBarPanel1的style属性改为OwnerDraw
------解决方案--------------------
好东西