none
关于 RRS feed

  • 问题

  •   Dim g As Graphics = e.Graphics
        Dim _TextBrush As Brush
    
        ' Get the item from the collection.
        '从汇集得到项目。 
        Dim _TabPage As TabPage = TabControl1.TabPages(e.Index)
    
        ' Get the real bounds for the tab rectangle.
        '“把真正的界限的标签长方形。
        Dim _TabBounds As Rectangle = TabControl1.GetTabRect(e.Index)
    
        If (e.State = DrawItemState.Selected) Then
          ' Draw a different background color, and don't paint a focus rectangle.
          ' “画一个不同的背景颜色,不要油漆焦点长方形。
          _TextBrush = New SolidBrush(Color.Yellow)
          g.FillRectangle(Brushes.Gray, e.Bounds)
        Else
          _TextBrush = New System.Drawing.SolidBrush(e.ForeColor)
          e.DrawBackground()
        End If
    
        ' Use our own font.
        '“用我们自己的字体。
        Dim _TabFont As New Font("幼圆", 15.0, FontStyle.Regular, GraphicsUnit.Pixel)
    
        ' Draw string. Center the text.
        '画线。中心的文本。
        Dim _StringFlags As New StringFormat()
        _StringFlags.Alignment = StringAlignment.Center
        _StringFlags.LineAlignment = StringAlignment.Center
        g.DrawString(_TabPage.Text, _TabFont, _TextBrush, _TabBounds, New StringFormat(_StringFlags))
    
    在标签添加图片~各位专家!谢谢!
    2011年2月19日 11:42

答案

  •  Hi 酷睿,

    我想你要的应该是这种效果:(后面有图片)

      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim components = New Container()
        Dim myImages As New ImageList(components)
    
        myImages.Images.Add(Drawing.Bitmap.FromFile("D:\red.jpg"))
        myImages.Images.Add(Drawing.Bitmap.FromFile("D:\exception.jpg"))
    
        myImages.ColorDepth = ColorDepth.Depth8Bit
        myImages.ImageSize = New Size(16, 16)
        myImages.TransparentColor = Color.Transparent
    
        ' Displays images from myImages on the tabs of tabControl1.
        TabControl1.ImageList = myImages
    
        ' Specifies which image to display (on the tab of tabPage1) by its index.
        TabPage1.ImageIndex = 0
        TabPage2.ImageIndex = 1
      End Sub
    

     

    这是效果图:

    Best regards,


    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2011年2月25日 15:07
    版主

全部回复