Advertisement
vilgelmbb

Enlarge popup

Dec 4th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1. private FieldInfo _popupSearchFormFieldInfo;
  2.  
  3.         internal FieldInfo PopupSearchFormFieldInfo
  4.         {
  5.             get { return _popupSearchFormFieldInfo ?? (_popupSearchFormFieldInfo = GetPopupSearchFormFieldInfo()); }
  6.         }
  7.    
  8. public void SomeChooseBox_TextChanged(object sender, EventArgs e)
  9.         {
  10.             var cb = sender as MultiChooseBox;
  11.             if (cb != null && cb.Text.Trim().Length >= cb.SearchIndex)
  12.             {
  13.                 var popupSearchForm = PopupSearchFormFieldInfo.GetValue(cb);
  14.  
  15.                 var searchPopup = popupSearchForm as PopupBaseSizeableForm;
  16.                 if (searchPopup != null)
  17.                 {
  18.                     searchPopup.MaximumSize = new Size(400, 255);
  19.                     searchPopup.MaximumClientSize = new Size(400, 255);
  20.                     searchPopup.ClientSize = new Size(400, 255);
  21.                 }
  22.             }
  23.         }
  24.  
  25. private FieldInfo GetPopupSearchFormFieldInfo()
  26.         {
  27.             var fields = GetAllFields(typeof(MultiChooseBox));
  28.             FieldInfo fi = fields.Where(i => i.Name == "searchForm").Select(i => i).FirstOrDefault();
  29.             if (fi == null) return null;
  30.             return fi;
  31.         }
  32.  
  33. private IEnumerable<FieldInfo> GetAllFields(Type t)
  34.         {
  35.             if (t == null)
  36.                 return Enumerable.Empty<FieldInfo>();
  37.  
  38.             BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic |
  39.                                  BindingFlags.Static | BindingFlags.Instance |
  40.                                  BindingFlags.DeclaredOnly;
  41.             return t.GetFields(flags).Concat(GetAllFields(t.BaseType));
  42.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement