请教一下如何将 "System.Drawing.Brushes.Black" 转成 Brush 我使用以下方法不成功
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly(typeof(System.Drawing.Brushes));
string systempath = assembly.Location; Brush myBrushes = (Brush)Assembly.LoadFrom(systempath).CreateInstance("System.Drawing.Brushes.Black");
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly(typeof(System.Drawing.Brushes));
string systempath = assembly.Location; Brush myBrushes = (Brush)Assembly.LoadFrom(systempath).CreateInstance("System.Drawing.Brushes.Black");
解决方案 »
- 不与数据库连接的。datatable作为数据源dataGridView1.DataSource
- 关于QQ传文件,群发文件,在线等待,解决了马上散分。。急
- C# winform怎么显示时钟
- C# RDLC报表问题!
- 请教:c#中 *.aspx文件的代码编辑器有 设计(锁定) 和 源 两个编辑页 现在我想把设计页的锁定解除???
- 报表显示问题??....
- 请教高手.错误不会改!请教!
- 如何查找并得到一個已運行的窗體實例?
- 关于ReportServices急呀!!!!!!!!!!!!!!!!
- 怎么在 Form的load事件里,更改 Button 的属性?
- C# 创建excel并保存
- textbox数据不能更新。
是静态的,你无法创建。
string systempath = assembly.Location;
Assembly drawing = Assembly.LoadFrom(systempath);
Type brushes_type = drawing.GetType("System.Drawing.Brushes");
Brush br = brushes_type.GetProperty("Black").GetGetMethod().Invoke(null,null) as Brush;
if (pi != null)
{
Brush b1 = pi.GetValue(null, null) as Brush;
}
string colStr = "System.Drawing.Brushes.Black";
string [] colNameArr=colStr.Split(new char[]{'.'});
col.Name = colStr[colNameArr.Length];
SolidBrush brush = new SolidBrush(col);
如果是想做创建画刷的工厂,用自定义的类存Color、width等。
Brush b = new SolidBrush(Color.Black, 1);
你这段有问题哦,
错误 1 无法对属性或索引器“System.Drawing.Color.Name”赋值 -- 它是只读的