This is a migrated thread and some comments may be shown as answers.

Drop down list as in scheduler edit appointment

2 Answers 93 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 07 Dec 2015, 01:03 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Dec 2015, 01:02 PM
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
0
Peter
Top achievements
Rank 1
answered on 09 Dec 2015, 11:04 AM

Hi.

Thank you. Great help.

Tags
DropDownList
Asked by
Peter
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Peter
Top achievements
Rank 1
Share this question
or