Answered Outlook To-Do bar, How-to

  • Friday, April 13, 2012 7:24 PM
     
     

    I have looked around the internets  for the last couple of days now for anything I can get on this, but to no avail.  I am trying to create an application that has an interface similar to the To-Do bar in Outlook, specifically the upcoming events that show below the calendar.

    I've tried a couple of different approaches but cannot achieve the same results.  Does anyone know of a way to duplicate this?

    I am not using my program as an add in to outlook, I just want a similar look for my program.


    • Edited by ThanklessPentium Friday, April 13, 2012 7:25 PM Forgot to add something.
    •  

All Replies

  • Friday, April 13, 2012 8:23 PM
    Moderator
     
     

    It seems like this could be reproduced pretty easily with a MonthCalendar and Buttons... what part is giving you problems?  If Button controls don't give you the right "look" you could always create a simple custom control instead.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • Friday, April 13, 2012 9:21 PM
     
      Has Code

    I figured buttons would be the way to go and tried to use buttons, but I just can't seem to wrap my mind around formatting the text; i.e. making some text bold while other text is regular, inserting new lines into the buttons text, etc.

    I'm using the GData Calendar API to interface with my application, and I have code which programmatically creates the buttons and places them into a Flow Layout Panel.  I'm just not sure how to make it look like the Outlook equivalent.  The code block that does this is below:

    For Each gFeedEntry As Google.GData.Calendar.EventEntry In gCalFeed.Entries
                Dim item As New Button
                With item
                    .Text = gFeedEntry.Title.Text
                    .Width = flpAppointments.Width - 2
                    .Height = 50
                    .TextAlign = ContentAlignment.TopLeft
                End With
                flpAppointments.Controls.Add(item)
            Next

  • Sunday, April 15, 2012 4:16 PM
    Moderator
     
     Answered Has Code

    You could customize a button to make your own control with the custom text formatting.

    Something like the following might work for you (though you may want to further customize the text rendering):

    Public Class CalendarEventButton
        Inherits Button
    
        Private _Caption As String
        Public Property Caption As String
            Get
                Return _Caption
            End Get
            Set(value As String)
                _Caption = value
                Invalidate()
            End Set
        End Property
    
        Private _Description As String
        Public Property Description As String
            Get
                Return _Description
            End Get
            Set(value As String)
                _Description = value
                Invalidate()
            End Set
        End Property
    
        Private _BoldFont As Font
        Public Overrides Property Font As System.Drawing.Font
            Get
                Return MyBase.Font
            End Get
            Set(value As System.Drawing.Font)
                _BoldFont = New Font(value, FontStyle.Bold)
                MyBase.Font = value
            End Set
        End Property
    
        Private _TextBrush As Brush
        Public Overrides Property ForeColor As System.Drawing.Color
            Get
                Return MyBase.ForeColor
            End Get
            Set(value As System.Drawing.Color)
                _TextBrush = New SolidBrush(value)
                MyBase.ForeColor = value
            End Set
        End Property
    
        Public Overrides Property Text As String
            Get
                Return String.Empty
            End Get
            Set(value As String)
                MyBase.Text = value
            End Set
        End Property
    
        Public Sub New()
            Size = New Size(124, 38)
            Text = String.Empty
            _BoldFont = New Font(Font, FontStyle.Bold)
            _Caption = "New Event"
            _Description = "(no event information)"
            _TextBrush = New SolidBrush(ForeColor)
        End Sub
    
        Protected Overrides Sub OnPaint(pevent As System.Windows.Forms.PaintEventArgs)
            MyBase.OnPaint(pevent)
            pevent.Graphics.DrawString(_Caption, _BoldFont, _TextBrush, New Point(4, 2))
            pevent.Graphics.DrawString(_Description, Font, _TextBrush, New Point(4, 2 + Font.Height * 1.25))
        End Sub
    End Class
    

    You would use this CalendarEventButton instead of regular Buttons, setting the Caption and Description and ignoring the Text property.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • Monday, April 16, 2012 1:36 PM
     
     
    Nice!  Thanks so much, this is what I was looking for!