or
| using System; |
| using System.Collections.Generic; |
| using System.Linq; |
| using Telerik.WinControls; |
| using Telerik.WinControls.UI; |
| /// <summary> |
| /// Wrapper class to make RadComboBox act like a WinForms ComboBox |
| /// when DropDownStyle is DropDownList |
| /// </summary> |
| /// <!--Author: Michael Gerety--> |
| public class WorkingDropDownList : RadComboBox |
| { |
| private char _lastChar; |
| private int _lastIndex; |
| private Dictionary<char, List<RadComboBoxItem>> _cache; |
| public override string ThemeClassName |
| { |
| get |
| { |
| return "Telerik.WinControls.UI.RadComboBox"; |
| } |
| set |
| { |
| base.ThemeClassName = value; |
| } |
| } |
| public WorkingDropDownList() |
| { |
| KeyPress += ComboBox_KeyPress; |
| _cache = new Dictionary<char, List<RadComboBoxItem>>(); |
| Items.ItemsChanged += new ItemChangedDelegate(Items_ItemsChanged); |
| } |
| void Items_ItemsChanged(RadItemCollection changed, RadItem target, ItemsChangeOperation operation) |
| { |
| //If the items collection changes, we need to remove the cache for the character affected. |
| if(target.Text != null) |
| { |
| var changedChar = Char.Parse(target.Text.Substring(0, 1)); |
| if(_cache.ContainsKey(changedChar)) |
| { |
| _cache.Remove(changedChar); |
| } |
| } |
| } |
| void ComboBox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) |
| { |
| if (DropDownStyle == RadDropDownStyle.DropDownList) |
| { |
| if (Char.IsLetter(e.KeyChar)) |
| { |
| if (Char.ToUpper(e.KeyChar) != _lastChar) |
| { |
| _lastChar = Char.ToUpper(e.KeyChar); |
| _lastIndex = 0; |
| if (!_cache.ContainsKey(_lastChar)) |
| { |
| var list = (from i in Items |
| where (i as RadComboBoxItem).Text.ToUpper().StartsWith(_lastChar.ToString()) |
| select (RadComboBoxItem)i).ToList(); |
| _cache.Add(_lastChar, list); |
| } |
| } |
| if (_lastIndex >= _cache[_lastChar].Count) |
| { |
| _lastIndex = 0; |
| } |
| if (_cache[_lastChar].Count > 0) |
| { |
| SelectedItem = _cache[_lastChar][_lastIndex]; |
| } |
| _lastIndex++; |
| } |
| } |
| } |
| } |
| <pro:RadAjaxManager ID="RadAjaxManager1" EnableAJAX="true" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"> |
| <AjaxSettings> |
| <pro:AjaxSetting AjaxControlID="CalendarRadScheduler"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="CalendarRadScheduler" LoadingPanelID="RadAjaxLoadingPanel1" /> |
| </UpdatedControls> |
| </pro:AjaxSetting> |
| </AjaxSettings> |
| </pro:RadAjaxManager> |
| <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server" /> |
| <pro:RadScheduler |
| ID="CalendarRadScheduler" |
| runat="server" |
| EnableAjaxSkinRendering="false" |
| Height="750px" |
| Width="578px" |
| ShowAllDayRow="False" |
| AllowDelete="False" |
| AllowEdit="False" |
| AllowInsert="False" |
| Skin="Office2007" |
| HoursPanelTimeFormat="h:mm tt" |
| MinutesPerRow="15" |
| ShowFullTime="True" |
| StartEditingInAdvancedForm="false" |
| DataKeyField="ID" |
| DataSubjectField="Subject" |
| DataStartField="Start" |
| DataEndField="End" |
| DataRecurrenceField="RecurrenceRule" |
| DataRecurrenceParentKeyField="RecurrenceParentID" |
| DayEndTime="18:30:00" |
| DayStartTime="08:00:00" |
| ShowFooter="false" |
| OnClientAppointmentInserting="AppointmentInserting" |
| OnClientAppointmentDoubleClick="AppointmentDoubleClick" |
| OnAppointmentCreated="CalendarRadScheduler_AppointmentCreated" |
| OnAppointmentDataBound="CalendarRadScheduler_AppointmentDataBound" |
| CustomAttributeNames="NetworkId" |
| OnAppointmentCommand="CalendarRadScheduler_AppointmentCommand" |
| OnFormCreating="CalendarRadScheduler_FormCreating"> |
| <AppointmentTemplate> |
| <div> |
| <%# FormatCalendarMessage() %> |
| <span style="text-align:right; vertical-align:top; width:100%;"> |
| <asp:ImageButton Enabled="true" Visible="false" ID="ibtnEdit" runat="server" CommandName="EditMessage" |
| ToolTip="Edit" AlternateText="Edit" CausesValidation="false" CssClass="linkButton" |
| ImageUrl="~/images/edit.gif" OnClientClick="ChangeImg(this.id, 'loading');" /> |
| |
| <asp:ImageButton Enabled="true" Visible="false" ID="ibtnCopy" runat="server" CommandName="CopyMessage" |
| ToolTip="Create Copy" AlternateText="Create Copy" CausesValidation="false" CssClass="linkButton" |
| ImageUrl="~/images/copy.gif" OnClientClick="ChangeImg(this.id, 'loading');" /> |
| </span> |
| </div> |
| </AppointmentTemplate> |
| </pro:RadScheduler> |