Drop down list as in scheduler edit appointment

3 posts, 1 answers
  1. Peter
    Peter avatar
    6 posts
    Member since:
    Nov 2015

    Posted 07 Dec 2015 Link to this post

    Hi.

    I have made my own Edit appointment form, and want to make a dropdownlist, just as the 'Background' selector.

    I simply can't figure out, how load the background colors in the scheduler into the dropdown.  

    My code look like this:

           Dim a As Int16

            Dim list(Me.uiRadSchedulerMain.Backgrounds.Count - 1) As String
            For a = 0 To Me.uiRadSchedulerMain.Backgrounds.Count - 1

                Dim dataItem As New RadListDataItem()
                dataItem.Text = Me.uiRadSchedulerMain.Backgrounds.Item(a).DisplayName.ToString
                dataItem.Image = ??? (background of backgrounds.item(a).[Image]) 
                dataItem.Value = Me.uiRadSchedulerMain.Backgrounds.Item(a).Id

                Me.comboBackground.Items.Add(dataItem)

            Next

    Kindly Peter

  2. Answer
    Dess
    Admin
    Dess avatar
    1605 posts

    Posted 08 Dec 2015 Link to this post

    Hello Peter,

    Thank you for writing back.
     
    Here is a sample code snippet demonstrating how to create a RadDropDownList similar to the one filled with scheduler's backgrounds:
    Public Class CustomAppointmentEditForm
        Private Function CreateImageByBackgroundInfo(backgroundInfo As IAppointmentBackgroundInfo) As Image
            Dim defaultImageSize As New Size(11, 11)
            Dim image As New Bitmap(defaultImageSize.Width, defaultImageSize.Height)
            Dim graphics__1 As Graphics = Graphics.FromImage(image)
     
            Dim rect As New Rectangle(Point.Empty, defaultImageSize)
            rect.Inflate(-1, -1)
            Using path As GraphicsPath = (New RoundRectShape(1)).CreatePath(rect)
                Using gradientBrush As New LinearGradientBrush(rect, backgroundInfo.BackColor, _
                                                               backgroundInfo.BackColor2, backgroundInfo.GradientAngle)
                    graphics__1.FillPath(gradientBrush, path)
                End Using
     
                Using pen As New Pen(backgroundInfo.BorderColor)
                    graphics__1.DrawPath(pen, path)
                End Using
            End Using
     
            Return image
        End Function
        Protected Overrides Sub LoadBackgrounds()
            MyBase.LoadBackgrounds()
            Dim scheduler As RadScheduler = TryCast(Me.SchedulerData, RadScheduler)
            Me.RadDropDownList1.DataSource = scheduler.GetBackgroundStorage()
            Me.RadDropDownList1.DisplayMember = "DisplayName"
            Me.RadDropDownList1.ValueMember = "Id"
            For Each item As RadListDataItem In Me.RadDropDownList1.Items
                item.Image = CreateImageByBackgroundInfo(item.DataBoundItem)
            Next
        End Sub
    End Class

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Peter avatar
    6 posts
    Member since:
    Nov 2015

    Posted 09 Dec 2015 in reply to Dess Link to this post

    Hi.

    Thank you. Great help.

Back to Top