예제 #1
0
 /// <summary>
 /// 多列过滤
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="colName1"></param>
 /// <param name="colName2"></param>
 public static void FilterLookup(object sender, string colName1, string colName2)
 {
     try
     {
         GridLookUpEdit edit = sender as GridLookUpEdit;
         if (edit != null)
         {
             if (!string.IsNullOrEmpty(edit.AutoSearchText.Trim()))
             {
                 GridView       gridView        = edit.Properties.View;
                 FieldInfo      fi              = gridView.GetType().GetField("extraFilter", BindingFlags.NonPublic | BindingFlags.Instance);
                 BinaryOperator op1             = new BinaryOperator(colName1, "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like);
                 BinaryOperator op2             = new BinaryOperator(colName2, "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like);
                 var            filterCondition = new GroupOperator(GroupOperatorType.Or, new CriteriaOperator[] { op1, op2 }).ToString();
                 if (fi != null)
                 {
                     fi.SetValue(gridView, filterCondition);
                     edit.ShowPopup();
                     edit.SelectionStart  = edit.Text.Length + 10; //设置选中文字的开始位置为文本框的文字的长度,如果超过了文本长度,则默认为文本的最后。
                     edit.SelectionLength = 0;                     //设置被选中文字的长度为0(将光标移动到文字最后)
                     edit.ScrollToCaret();                         //讲滚动条移动到光标位置
                 }
                 MethodInfo mi = gridView.GetType().GetMethod("ApplyColumnsFilterEx", BindingFlags.NonPublic | BindingFlags.Instance);
                 mi.Invoke(gridView, null);
             }
             else
             {
                 if (string.IsNullOrEmpty(edit.Text.Trim()))
                 {
                     if (edit.Properties.NullValuePrompt == "格式:江苏省-苏州市-吴中区")
                     {
                         return;
                     }
                     edit.ShowPopup();
                     edit.SelectionStart  = edit.Text.Length + 10; //设置选中文字的开始位置为文本框的文字的长度,如果超过了文本长度,则默认为文本的最后。
                     edit.SelectionLength = 0;                     //设置被选中文字的长度为0(将光标移动到文字最后)
                     edit.ScrollToCaret();                         //讲滚动条移动到光标位置
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogUtil.WriteException(ex);
     }
 }
예제 #2
0
 private void gridViewDetail_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
 {
     try
     {
         if (gridViewDetail.FocusedColumn.RealColumnEdit is RepositoryItemGridLookUpEdit)
         {
             gridViewDetail.ShowEditor();
             GridLookUpEdit edit = gridViewDetail.ActiveEditor as GridLookUpEdit;
             edit.ShowPopup();
         }
     }
     catch (Exception ex)
     {
     }
 }
예제 #3
0
        protected virtual void gridLookUpEdit_Enter(object sender, EventArgs e)
        {
            GridLookUpEdit lookUp = sender as GridLookUpEdit;

            BeginInvoke(new Action(() => { lookUp.ShowPopup(); }));
        }