hi frnds, I want to add cross button image on the right hand side of tabPage...I m creating tabpages at Runtime....
Mine code is added image to the left...I want to add it to the right....I m also adding text to the tabPage...

& second Probs is dat..On button click suppose i add the first tab Page,Image is aded to the first Tab Page...When i click on button to create the second Tab,Image & text of First Tab Page is clear & so on...

PLZ help me on this matter
Mine code below-

Public Class Form2
    Dim TabPageIndex As Integer
    Dim tab As TabPage = New TabPage("SONIA SARDANA")
    Public Sub New()
        TabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed
    End Sub

    Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs)

            Dim recBounds As Rectangle = Me.TabControl1.GetTabRect(TabPageIndex)
            Dim tabTextArea As RectangleF = _
                   CType(Me.TabControl1.GetTabRect(TabPageIndex), RectangleF)

            Dim img As Image = ImgIcons.Images(0)

            Dim nLeftMargin As Integer = 8
            Dim nRightMargin As Integer = 2

            Dim rimage As Rectangle = New Rectangle(recBounds.X + _
                       nLeftMargin, recBounds.Y + 1, img.Width, img.Height)
            Dim nAdj As Single = CType((nLeftMargin + _
                        img.Width + nRightMargin), Single)
            rimage.Y += (recBounds.Height - img.Height) / 2
            tabTextArea.X += nAdj
            tabTextArea.Width -= nAdj

            e.Graphics.DrawImage(img, rimage)
            Dim stringFormat As StringFormat = New StringFormat
            stringFormat.Alignment = StringAlignment.Center
            stringFormat.LineAlignment = StringAlignment.Center

            Dim br As Brush
            br = New SolidBrush(Color.Black)
            e.Graphics.DrawString(tab.Text, Me.Font, Brushes.Black, tabTextArea, stringFormat)

        Catch ex As Exception
        End Try
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Static lTabIndex As Integer
            lTabIndex = lTabIndex + 1
            tab.Name = "Tab" & lTabIndex
            TabPageIndex = TabControl1.TabPages.Count - 1
            AddHandler TabControl1.DrawItem, AddressOf TabControl1_DrawItem

        Catch ex As Exception
        End Try
    End Sub
End Class
This article has been dead for over six months. Start a new discussion instead.