Hello,
I need to hide the "Action" tab in the Appointment Dialog (I want to show only the "Description" tab).Is it possible?
Thank youMTGC Staff
There is no way to modify the stock appointment dialog via the public object model. The AppointmentDialog class, however, is publicly exposed and derives from System.Windows.Forms.Form, so you can use the usual methodology when dealing with forms to modify a control that belongs to it, like so:
private void calendarInfo_BeforeDisplayAppointmentDialog(object sender, DisplayAppointmentDialogEventArgs e){ UltraCalendarInfo calendarInfo = sender as UltraCalendarInfo; e.Cancel = true; AppointmentDialog dialog = new AppointmentDialog( calendarInfo, e.Appointment, e.IsExistingAppointment );
Infragistics.Win.UltraWinTabControl.UltraTabControl tabControl = this.FindTabControl( dialog.Controls );
if ( tabControl != null && tabControl.Tabs.Exists("Action") ) tabControl.Tabs["Action"].Visible = false;
dialog.Show();}
private Infragistics.Win.UltraWinTabControl.UltraTabControl FindTabControl( Control.ControlCollection controls ){ if ( controls == null || controls.Count == 0 ) return null;
foreach ( Control control in controls ) { Infragistics.Win.UltraWinTabControl.UltraTabControl tabControl = control as Infragistics.Win.UltraWinTabControl.UltraTabControl;
if ( tabControl != null ) return tabControl; else { tabControl = this.FindTabControl( control.Controls );
if ( tabControl != null ) return tabControl; } }
return null;}
Please note that changes like this are unsupported, since we reserve the future right to change our default dialog in ways that could potentially break code like this.
Apologies for the thread necromancy, but I recently had to do exactly this. This old code no longer works, as the structure of the appointments form has changed. I have some updated code that does work, at least with v18.1.
The advantage of this code is, with come modifications to the FindControl function to search by name, you can use it to modify other parts of the form, like hiding the "Location" dropdown.
This is vb.net code, but you can translate it for C#.
Private Sub UltraCalendarInfo1_BeforeDisplayAppointmentDialog(sender As Object, e As DisplayAppointmentDialogEventArgs) Handles UltraCalendarInfo1.BeforeDisplayAppointmentDialog Dim uciCalendar As UltraCalendarInfo = DirectCast(sender, UltraCalendarInfo) Dim utcTabControl As UltraWinTabControl.UltraTabControl e.Cancel = True Using adDialog As New AppointmentDialog(uciCalendar, e.Appointment, e.IsExistingAppointment) utcTabControl = FindControl(Of UltraWinTabControl.UltraTabControl)(adDialog) If utcTabControl IsNot Nothing AndAlso utcTabControl.Tabs.Exists("Action") Then utcTabControl.Tabs("Action").Visible = False End If adDialog.ShowDialog(Me) End Using End Sub Private Function FindControl(Of T As Control)(cParentControl As Control) As T Dim cFoundControl As Control = Nothing If cParentControl Is Nothing OrElse cParentControl.Controls Is Nothing OrElse cParentControl.Controls.Count = 0 Then Return Nothing End If For Each cControl As Control In cParentControl.Controls If cControl.GetType().Equals(GetType(T)) Then cFoundControl = cControl Exit For Else cFoundControl = FindControl(Of T)(cControl) If cFoundControl IsNot Nothing Then Exit For End If End If Next Return cFoundControl End Function
Thank you very much, I will try it.