DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 1 of 1
  1. #1
    Join Date
    Apr 2009
    Posts
    10

    TabPage Image + DrawItem

    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 Right along with the text at the left...

    I want to just ask that is that possible to write the code the image...so dat i m able to close tab when i click on the image
    PLZ help me on this matter
    Mine code below that is adding tab at runtime along with image-

    Code:
    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 img As Image = ImgIcons.Images(0)
    
                Dim _imageLocation As Point = New Point(15, 5)
                Dim _imgHitArea As Point = New Point(13, 2)
    
    
                Dim r As Rectangle = e.Bounds
                r = Me.TabControl1.GetTabRect(e.Index)
                r.Offset(2, 2)
    
                Dim TitleBrush As Brush = New SolidBrush(Color.Black)
                Dim f As Font = Me.Font
    
                Dim title As String = Me.TabControl1.TabPages(e.Index).Text
                e.Graphics.DrawString(title, f, TitleBrush, New PointF(r.X, r.Y))
                e.Graphics.DrawImage(img, New Point(r.X + (Me.TabControl1.GetTabRect(e.Index).Width - _imageLocation.X), _imageLocation.Y))
    
            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
    Last edited by sonia sardana; 06-14-2009 at 03:24 PM.

Similar Threads

  1. Replies: 4
    Last Post: 10-23-2011, 02:47 PM
  2. Image won't display in Applet
    By syntax_error0 in forum Java
    Replies: 1
    Last Post: 02-06-2006, 01:33 AM
  3. help regarding image processing
    By laxmi in forum Java
    Replies: 6
    Last Post: 02-03-2006, 12:55 PM
  4. Replies: 0
    Last Post: 07-11-2005, 09:41 PM
  5. Script for scrolling
    By Mark in forum Web
    Replies: 3
    Last Post: 08-30-2001, 11:45 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links