Is it possible to drag and drop from a grid view to a scheduler then the appointment will be set automatically??

13 posts, 0 answers
  1. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 19 Apr 2011 Link to this post

    Is it possible to drag and drop from a grid view to a scheduler then the appointment will be set and save automatically??

     

    For example in the same window I have grid view and   scheduler

    If there is a person call John in grid view that has a kind of an appointment, so when I drag that person from grid to scheduler the appointment should be automatically added to the selected place and time.


    For more detail check the attached picture



    Thanks in advance
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 19 Apr 2011 Link to this post

    Hello Anoop,

    Yes, you can do this. Please open up the Telerik Winforms demons that are on your PC and navigate to the Scheduler demos, and then drag&drop. You will see that this scenario is covered in the demos. I.e there is a demo of a drag drop from RadGridView to RadScheduler to create an appointment.
    Hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 20 Apr 2011 Link to this post

    Thanks a lot Richard,,

    I tried this small example since I do not know how to use or run demos codes its using some extra classes and such a thing witch is not working well with me.

    But I could not understand how to declare the drag object

     

    Dim dragObject As DragObject = TryCast(e.Data.GetData(GetType(DragObject)), DragObject)

     

    This object is giving me an error that it can not be declare

     

    If you have any idea please letme know since it might need to add some reference or such a thing

    the above line give me an errror and this two line of code too coz it is related to the above one as I believe  

     

     
    Me
    .mouseDownPosition = point.Empty

     

     

     

    Me.isDragging = False

     



    ublic Class RadForm1
      
      
        Private Sub radScheduler1_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs)
            Dim point As Point = Me.radScheduler1.PointToClient(New Point(e.X, e.Y))
      
            Dim table As DayViewAppointmentsTable = (TryCast(Me.radScheduler1.SchedulerElement.ViewElement, SchedulerDayViewElement)).DataAreaElement.Table
            Dim schedulerCell As SchedulerCellElement = SchedulerUIHelper.GetCellAtPoint(point, table.Children)
            If schedulerCell IsNot Nothing Then
      
                Dim dragObject As DragObject = TryCast(e.Data.GetData(GetType(DragObject)), DragObject)
                If dragObject IsNot Nothing Then
                    Me.RadScheduler1.Appointments.BeginUpdate()
                    Dim appointment As Appointment = CreateAppointment(schedulerCell.Date, dragObject)
                    Me.RadScheduler1.Appointments.Add(appointment)
                    Me.RadScheduler1.Appointments.EndUpdate()
                End If
            End If
      
            Me.mouseDownPosition = point.Empty
            Me.isDragging = False
        End Sub
        Private Function CreateAppointment(ByVal currentDate As Date, ByVal dragObject As DragObject) As Appointment
            Dim appointment As New Appointment()
            Dim startDate As Date = currentDate
            Dim endDate As Date = currentDate.AddHours(1)
            Select Case dragObject.Status
                Case AppointmentFields.Summary
                    appointment.Summary = TryCast(dragObject.Values(dragObject.Status), String)
                Case AppointmentFields.Row
                    appointment.Summary = TryCast(dragObject.Values(AppointmentFields.Summary), String)
                    appointment.Description = TryCast(dragObject.Values(AppointmentFields.Description), String)
                    appointment.BackgroundId = CInt(Fix(dragObject.Values(AppointmentFields.Background)))
                    appointment.StatusId = CInt(Fix(dragObject.Values(AppointmentFields.Status)))
                    appointment.Location = TryCast(dragObject.Values(AppointmentFields.Location), String)
      
                    startDate = CDate(dragObject.Values(AppointmentFields.Start))
                    endDate = CDate(dragObject.Values(AppointmentFields.End))
      
                    Dim range As TimeSpan = endDate.Subtract(startDate)
                    endDate = currentDate.Add(range)
                    startDate = currentDate
      
            End Select
            appointment.Start = startDate
            appointment.End = endDate
            Return appointment
        End Function
      
        Private Sub RadScheduler1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadScheduler1.Click
      
        End Sub
        Private Enum AppointmentFields
            Row
            Summary
            Location
            Description
            Start
            [End]
            Background
            Status
        End Enum
    End Class
  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 20 Apr 2011 Link to this post

    Hello Anoop,

    It's really easy to get to the examples and you will find everything that you need in there. Just browse to (for exmaple)
     C:\Program Files (x86)\Telerik\RadControls for WinForms Q1 2011\Examples\QuickStart and then open the solution which is right for your environment. E.g. ExamplesCSVS2010.sln

    Hope that helps
    Richard
  6. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 20 Apr 2011 Link to this post

    How about the example I just post >>do you have any idea,,

    Dim dragObject As DragObject = TryCast(e.Data.GetData(GetType(DragObject)), DragObject)

     

    For the example I can run the demo and see the code, but my problem was with the code itself it’s giving me an error when I use it after creating a new project

  7. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 20 Apr 2011 Link to this post

    Hi Anoop,

    I'm having trouble understanding the issue that you're having. Have you tried the demo example?
    Richard
  8. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 21 Apr 2011 Link to this post

    the whole example is here(Link)

    but dragobject can not be declare I don’t know what is the reason behind that

     

    I need to understand how this object work

  9. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 21 Apr 2011 Link to this post

    Hello Anoop,

    The DragObject is an object that you write yourself that holds the information that you wish to drag. For exmaple, in the demo app, the DragObject is written as follows:

    Private Class DragObject            
      
    Private status_Renamed As AppointmentFields            
      
    Private values_Renamed As Dictionary(Of AppointmentFields, Object) = New Dictionary(Of AppointmentFields, Object)()      
      
    Public Property Status() As AppointmentFields                
        Get                    
            Return Me.status_Renamed                
        End Get                
            Set(ByVal value As AppointmentFields)                    
            Me.status_Renamed = value                
        End Set            
    End Property            
      
    Public ReadOnly Property Values() As Dictionary(Of AppointmentFields, Object)                
        Get                    
            Return Me.values_Renamed                
        End Get            
    End Property        
      
    End Class

    I hope that helps but do let me know if you need further help
    Richard
  10. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 22 Apr 2011 Link to this post

    Hi Anoop,

    Please remember to mark Richard's reply as answer if you find it helpful. Write back if you have additional questions.

    Best wishes,
    Ivan Todorov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  11. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 24 Apr 2011 Link to this post

    Thanks a lot
    how about this two line of code,,
    is there is any reference need to be added?

    Me.mouseDownPosition = point.Empty
            Me.isDragging = False
  12. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 25 Apr 2011 Link to this post

    Can you please let me know how drag and drop work in simple example using scheduler and grid view?



    thanks in advance
  13. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 26 Apr 2011 Link to this post

    Hello Anoop,

    Aside from the demos that you have already seen on your pc, please also take a look at this forum post which you may find helpful.
    Regards,
    Richard
  14. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 27 Apr 2011 Link to this post

    Hi Anoop,

    Have you managed to get this case working?

    Feel free to write if you need further help.

    Best wishes,
    Ivan Todorov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready