How to remove a ultraCalendarInfo appointment?

Posted by MBeynon on 16-Oct-2017 03:33

Hi,

I'm building a demo OE .NET app whereby items are dragged from a grid into a ultraCalendarInfo component;

myAppointment = NEW Infragistics.Win.UltraWinSchedule.Appointment(lvdStartTime, lvdEndTime).

myAppointment:Owner = ultraDayView1:GetOwnerFromPoint(ultraDayView1:PointToClient(NEW System.Drawing.Point(e:X, e:Y))).

ultraCalendarInfo1:Appointments:Add(myAppointment).

I want to programatically delete selected appointments from a right click context menu rather than double clicking the appointment to open the info pane (or hitting the delte key);

	METHOD PRIVATE VOID deleteToolStripMenuItem_Click( INPUT sender AS System.Object, INPUT e AS System.EventArgs ):
	  
	  DEFINE VARIABLE i AS INTEGER NO-UNDO.
	  DEFINE VARIABLE lvlSuccess AS LOGICAL NO-UNDO.

    
    DO i = 0 TO ultraCalendarInfo1:SelectedAppointments:Count - 1:
    

      
      ultraCalendarInfo1:SelectedAppointments:Remove(ultraCalendarInfo1:SelectedAppointments:Item[i]).
      ultraCalendarInfo1:SelectedAppointments:Clear().

    END.
    
		RETURN.

	END METHOD.

The problem is that neither of the commands above works!

Would someone be able to explain what I've done wrong?

Many Thanks,

Mark.

Posted by Mike Fechner on 16-Oct-2017 04:01

I haven't used the ultraCalendarInfo for a while ...

But generally:

In the deleteToolStripMenuItem, oyu are iterating the SelectedAppointments collection from 0 to max.

In the first iteration you're removing the first item from the selected appointments (that is typically just unselecting it, not removing it) and then you clear the entire collection. So there's never be a second item you will remove.

Just calling Clear (without the loop) would be enough to unselect the items.

But it you want to remove the selected appointments, I'd rather do something like this (untested) to remove the selected items from the Appointments collection itself.:

DO i = ultraCalendarInfo1:SelectedAppointments:Count - 1 TO 0 BY -1:
  
ultraCalendarInfo1:Appointments:Remove(ultraCalendarInfo1:SelectedAppointments:Item[i]).
 
END.


All Replies

Posted by Mike Fechner on 16-Oct-2017 04:01

I haven't used the ultraCalendarInfo for a while ...

But generally:

In the deleteToolStripMenuItem, oyu are iterating the SelectedAppointments collection from 0 to max.

In the first iteration you're removing the first item from the selected appointments (that is typically just unselecting it, not removing it) and then you clear the entire collection. So there's never be a second item you will remove.

Just calling Clear (without the loop) would be enough to unselect the items.

But it you want to remove the selected appointments, I'd rather do something like this (untested) to remove the selected items from the Appointments collection itself.:

DO i = ultraCalendarInfo1:SelectedAppointments:Count - 1 TO 0 BY -1:
  
ultraCalendarInfo1:Appointments:Remove(ultraCalendarInfo1:SelectedAppointments:Item[i]).
 
END.


Posted by MBeynon on 16-Oct-2017 04:09

Thanks Mike. That works a treat!

This thread is closed