我已经使用图形的填充属性创建了一个用户控件。这是一个圆圈。它就像一个速度计,因此它有许多颜色,并使用不同的形状填充。我需要让它具有空白空间,使背景颜色与默认颜色以外的其他颜色相同。如何改变图形的背景颜色?shape back color
回答
Graphics g = this.CreateGraphics();
SolidBrush myBrush = new SolidBrush(Color.Red);
g.FillEllipse(myBrush, ClientRectangle);
一个更完整的例子。这将填充UserControl的背景(基于用户控件的大小)为Pink,并创建一个填充了橙色背景色的小圆圈。
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
SolidBrush sb = new SolidBrush(Color.Pink);
g.FillRectangle(sb, e.ClipRectangle);
sb.Dispose();
sb = new SolidBrush(Color.Orange);
g.FillEllipse(sb, 20, 20, 20, 20);
sb.Dispose();
}
更多你在找什么?
如果你想要的背景颜色是一样的用户控制,改变这种:
SolidBrush sb = new SolidBrush(this.BackColor); //Color.Pink);
如果我没有错,将绘制红色的形状。我画了圆形的形状,就像是一个速度计,但我想要将具有形式颜色的空白空间设置为另一种颜色。例如, 。 图形g = this.CreateGraphics(); SolidBrush myBrush = new SolidBrush(Color.Red); g.FillEllipse(myBrush,ClientRectangle); 它创建一个红色矩形,但在该矩形内,我想要其他颜色。希望这是明确的... – Jankhana 2010-01-18 13:46:38
好的,我更新了我的例子,让我知道如果这就是你要找的。 – SwDevMan81 2010-01-18 15:15:14
嘿,这很好,我会尝试使用我的代码,并让你知道谢谢。 – Jankhana 2010-01-19 05:05:19
- 1. div class change color from color name to color #code
- 2. CSS3 Moon Eclipse shape
- 3. Shape blobs
- 4. DrawableCompat.setTint(drawable,color)vs Drawable.setColorFilter(color,mode)
- 5. CSS3 shape not postioning correctly
- 6. Toogle button font color and drawableft selector
- 7. shape fitting - gis
- 8. KineticJS shape over image
- 9. Processing Shape Placement
- 10. ng-click X3Dom shape
- 11. make UILabel roundrect shape
- 12. Tumblr Shape HTML
- 13. Hexagon shape btn-group
- 14. three.js shape holes height
- 15. 'location-changed'event not fired on user back back按钮
- 16. ng2-smart-table with back-end from back-end(Spring)
- 17. Apple Watch Complication Tint Color
- 18. Mediawiki:font color
- 19. 正则表达式换行$ {color}和$ color
- 20. CSS Transition Back倒退
- 21. 如何制作<area tag hotspot show color
- 22. CGAL 2D alpha shape outline
- 23. shape file(GIS)to text
- 24. GTFS Shape Extraneous Data Points
- 25. Android Listview/item/textview/shape
- 26. VB Form In Circle Shape
- 27. Java Circle Shape(6段)
- 28. NetworkX:从shape文件
- 29. UITextView resignFirstResponder Back on
- 30. preg_match a back slash
做我的最后一个职位回答这个问题?或者你还需要更多的帮助? – SwDevMan81 2010-01-18 19:56:58