以下代码来自网络上一篇文章,可是我运行的时候这一行出错;
g . FillRectangle ( new SolidBrush (  i  ) , myRec . X , myRec . Y , 20 , 10 ) ;
不可访问System.Drawing.SolidBrush.SolidBrush(it),因为它受保护级别;
我仔细检查过代码,和原文一样,请大家给解答一下。using System ;
using System . Collections ;
using System . ComponentModel ;
using System . Data ;
using System.Data.OleDb;
using System . Drawing ;
using System . Web ;
using System . Web . SessionState ;
using System . Web . UI ;
using System . Web . UI . WebControls ;
using System . Web . UI . HtmlControls ;
using System . Drawing . Imaging ;namespace datapic
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
public void Page_Load(object sender, System.EventArgs e)
{
string sRouter = "c:\\db.mdb" ;
//获得当前Access数据库在服务器端的绝对路径
string strCon = " Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " + sRouter ;
//创建一个数据库连接
OleDbConnection myConn = new OleDbConnection ( strCon ) ;
string strCom = " SELECT YF ,SL FROM Table01 ORDER BY YF" ;
myConn.Open ( ) ;
OleDbCommand myCommand = new OleDbCommand ( strCom , myConn ) ;
OleDbDataReader myOleDbDataReader = myCommand.ExecuteReader ( ) ;
//创建OleDbDataReader实例,并以此实例来获取数据库中各条记录数据
int [ ] iXiaoSH = new int [ 12 ] ;
//定义一个数组,用以存放从数据库中读取的销售数据
string [ ] sMoth = new string [ 12 ] ;
//定义一个数组,用以存放从数据库中读取的销售月份
int iIndex = 0 ;
while ( myOleDbDataReader.Read ( ) ) 
{
  iXiaoSH [ iIndex ] = myOleDbDataReader.GetInt32 ( 1 ) ;
  sMoth [ iIndex ] = myOleDbDataReader.GetInt32 ( 0 ) . ToString ( ) + "月" ;
  iIndex++ ;
}
//读取Table01数据表中的各条数据,并存放在先前定义的二个数组中
myConn . Close ( ) ;
myOleDbDataReader . Close ( ) ;
//关闭各种资源
Bitmap bm = new Bitmap ( 600 , 250 ) ;
//创建一个长度为600,宽带为250的Bitmap实例
Graphics g ;
g = Graphics.FromImage ( bm ) ;
//由此Bitmap实例创建Graphic实例
g . Clear ( Color . Snow ) ;
//用Snow色彩为背景色填充此绘画图面
g . DrawString ( " ××公司××器件2002年度销售情况一览表" , new Font ( "宋体" , 16 ) , Brushes . Black , new Point ( 5 , 5 ) ) ; //以下代码是是实现图01中的右上部
Point myRec = new Point ( 535 , 30 ) ;
Point myDec = new Point ( 560 , 26 ) ; //以上是在图01中为下面绘制定位
g . DrawString ( "单位:万套" , new Font ( "宋体" , 9 ) , Brushes . Black , new Point ( 525 , 12 ) ) ;
for ( int i = 0 ; i < sMoth.Length ; i++ ) 
{
g . DrawRectangle ( Pens.Black , myRec . X , myRec . Y , 20 , 10 ) ;
//绘制小方块
g . FillRectangle ( new SolidBrush (  i  ) , myRec . X , myRec . Y , 20 , 10 ) ;
//填充小方块
g . DrawString ( sMoth [ i ] . ToString ( ) , new Font ( "宋体" , 9 ) , Brushes . Black , myDec ) ;
//绘制小方块右边的文字
myRec . Y += 15 ;
myDec . Y += 15 ;
}
//以下代码是绘制图01中的Bar图,及其销售数量
int iBarWidth = 40 ;
int scale = 10 ;
for ( int i = 0 ; i < iXiaoSH . Length ; i++ ) 
{
g . DrawRectangle ( Pens.Black , ( i * iBarWidth ) + 15 , 250 - ( iXiaoSH [ i ] * scale ) , 20 , ( iXiaoSH [ i ] * scale ) + 5 ) ;
//绘制Bar图
g . FillRectangle ( new SolidBrush (  i ) , ( i * iBarWidth ) + 15 , 250 - ( iXiaoSH [ i ] * scale ) , 20 , ( iXiaoSH [ i ] * scale ) + 5 ) ;
//以指定的色彩填充Bar图
g . DrawString ( iXiaoSH [ i ] . ToString ( ) , new Font ( "宋体" , 9 ) , Brushes . Black , ( i * iBarWidth ) + 20 , 235 - ( iXiaoSH [ i ] * scale ) ) ;
//显示Bar图代表的数据
}
Pen p = new Pen ( Color.Black , 2 ) ;
g . DrawRectangle ( p , 1 , 1 , 598 , 248 ) ;
bm.Save ( Response . OutputStream , ImageFormat . Jpeg ) ;

}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{    
this.Load += new System.EventHandler(this.Page_Load); }
private Color GetColor ( int itemIndex ) 
{
  Color MyColor ;
  int i = itemIndex ;
  switch ( i ) 
  {
   case 0 :
    MyColor = Color . Cornsilk ;
    return MyColor ;
   case 1 :
    MyColor = Color . Red ;
    return MyColor ;
   case 2 :
    MyColor = Color . Yellow ;
    return MyColor ;
   case 3 :
    MyColor = Color . Peru ;
    return MyColor ;
   case 4 :
    MyColor = Color . Orange ;
    return MyColor ;
   case 5 :
    MyColor = Color . Coral ;
    return MyColor ;
   case 6:
    MyColor = Color . Gray ;
    return MyColor ;
   case 7:
    MyColor = Color . Maroon ;
    return MyColor ;
   case 8:
    MyColor = Color . Azure ;
    return MyColor ;
   case 9:
    MyColor = Color.AliceBlue ;
    return MyColor ;
   case 10:
    MyColor = Color . Bisque ;
    return MyColor ;
   case 11:
    MyColor = Color . BurlyWood ;
    return MyColor ;
   case 12:
    MyColor = Color . Chartreuse ;
    return MyColor ;
   default:
    MyColor = Color . Green ;
    return MyColor ;
 }
}
#endregion

}
}
}