Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private FieldInfo _popupSearchFormFieldInfo;
- internal FieldInfo PopupSearchFormFieldInfo
- {
- get { return _popupSearchFormFieldInfo ?? (_popupSearchFormFieldInfo = GetPopupSearchFormFieldInfo()); }
- }
- public void SomeChooseBox_TextChanged(object sender, EventArgs e)
- {
- var cb = sender as MultiChooseBox;
- if (cb != null && cb.Text.Trim().Length >= cb.SearchIndex)
- {
- var popupSearchForm = PopupSearchFormFieldInfo.GetValue(cb);
- var searchPopup = popupSearchForm as PopupBaseSizeableForm;
- if (searchPopup != null)
- {
- searchPopup.MaximumSize = new Size(400, 255);
- searchPopup.MaximumClientSize = new Size(400, 255);
- searchPopup.ClientSize = new Size(400, 255);
- }
- }
- }
- private FieldInfo GetPopupSearchFormFieldInfo()
- {
- var fields = GetAllFields(typeof(MultiChooseBox));
- FieldInfo fi = fields.Where(i => i.Name == "searchForm").Select(i => i).FirstOrDefault();
- if (fi == null) return null;
- return fi;
- }
- private IEnumerable<FieldInfo> GetAllFields(Type t)
- {
- if (t == null)
- return Enumerable.Empty<FieldInfo>();
- BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic |
- BindingFlags.Static | BindingFlags.Instance |
- BindingFlags.DeclaredOnly;
- return t.GetFields(flags).Concat(GetAllFields(t.BaseType));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement