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()
        InitializeComponent()
        TabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed
    End Sub

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

            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
            MsgBox(ex.Message)
        End Try
    End Sub


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

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class

for the image you can check out this link http://www.codeproject.com/KB/dotnet/CustomTabControl.aspx

for the second thing you can use

Private Sub TabControl1_Deselected(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles TabControl1.Deselected
'remove image index and text
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.