晕啊。给那么多废话。关键的代码翻译一下不就可以了。那些自动生成的也改写。懒啊。下班了。回家了。一会回家看看。vb.net我用的比较多的是静态绑定,动态绑定不如c#这么容易写。(也许是因为我菜)回去瞅瞅

解决方案 »

  1.   

    ctrl.Paint += new PaintEventHandler(ctrl_Paint);
    private void ctrl_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
    Image img = this.Icon.ToBitmap(); switch(this.index)
    {
    case "平铺" :
    e.Graphics.DrawImage(img, new Rectangle(0,0,this.Width-1,this.Height-1));
    break;
    case "层叠" :
    for(int i=0; i<=this.Width / img.Width; i++)
    for(int j=0; j<=this.Height/img.Height; j++)
    e.Graphics.DrawImage(img, new Point(i*img.Width, j*img.Height));
    break;
    case "居中" :
    e.Graphics.DrawImage(img, new Point((this.Width-img.Width)/2, (this.Height-img.Height)/2));
    break;
    }
    }关键就是上台这两短,谁会啊
      

  2.   

    你可以这样。
    估计你的ctrl是个panel吧。vb.net里,支持事件的静态绑定。你可以先画好控件,然后双击panel,就可以直接编写paint事件了。
    翻译如下;
    dim img as new Image(this.Icon.ToBitmap())
    select case this.index
    case "平铺" 
    e.Graphics.DrawImage(img, new Rectangle(0,0,this.Width-1,this.Height-1))
    case "层叠" 
    dim  i,j as int32
    for i=0 to i<=this.Width / img.Width
    for j=0 to j<=this.Height/img.Height
    next
    next
    e.Graphics.DrawImage(img, new Point(i*img.Width, j*img.Height))
    case "居中" 
    e.Graphics.DrawImage(img, new Point((this.Width-img.Width)/2, (this.Height-img.Height)/2));
    end select