请C#大侠帮忙翻译这段代码为VB.Net的,谢谢了!
voidgridLookUpEdit1_Popup(objectsender,EventArgse){FilterLookup(sender);}privatevoidF...
void gridLookUpEdit1_Popup(object sender, EventArgs e)
{
FilterLookup(sender);
}
private void FilterLookup(object sender) {
Text += " ! ";
GridLookUpEdit edit = sender as GridLookUpEdit;
GridView gridView = edit.Properties.View as GridView;
FieldInfo fi = gridView.GetType().GetField("extraFilter", BindingFlags.NonPublic | BindingFlags.Instance);
Text = edit.AutoSearchText;
BinaryOperator op1 = new BinaryOperator("Code", edit.AutoSearchText + "%", BinaryOperatorType.Like);
BinaryOperator op2 = new BinaryOperator("Name", edit.AutoSearchText + "%", BinaryOperatorType.Like);
string filterCondition = new GroupOperator(GroupOperatorType.Or, new CriteriaOperator[] { op1, op2 }).ToString();
fi.SetValue(gridView, filterCondition);
MethodInfo mi = gridView.GetType().GetMethod("ApplyColumnsFilterEx", BindingFlags.NonPublic | BindingFlags.Instance);
mi.Invoke(gridView, null);
}
private void gridLookUpEdit1_EditValueChanging(object sender, ChangingEventArgs e) {
this.BeginInvoke(new System.Windows.Forms.MethodInvoker(delegate{
FilterLookup(sender);
}));
}
--------------------------------------------------------------------------------------------------
请C#大侠帮小弟将上述代码翻译成VB.Net的,谢谢了!
最主要是下面(private void gridLookUpEdit1_EditValueChanging)那段。
不要用工具转换的,因为我也用过此类工具,错误太多!
非常感谢! 展开
{
FilterLookup(sender);
}
private void FilterLookup(object sender) {
Text += " ! ";
GridLookUpEdit edit = sender as GridLookUpEdit;
GridView gridView = edit.Properties.View as GridView;
FieldInfo fi = gridView.GetType().GetField("extraFilter", BindingFlags.NonPublic | BindingFlags.Instance);
Text = edit.AutoSearchText;
BinaryOperator op1 = new BinaryOperator("Code", edit.AutoSearchText + "%", BinaryOperatorType.Like);
BinaryOperator op2 = new BinaryOperator("Name", edit.AutoSearchText + "%", BinaryOperatorType.Like);
string filterCondition = new GroupOperator(GroupOperatorType.Or, new CriteriaOperator[] { op1, op2 }).ToString();
fi.SetValue(gridView, filterCondition);
MethodInfo mi = gridView.GetType().GetMethod("ApplyColumnsFilterEx", BindingFlags.NonPublic | BindingFlags.Instance);
mi.Invoke(gridView, null);
}
private void gridLookUpEdit1_EditValueChanging(object sender, ChangingEventArgs e) {
this.BeginInvoke(new System.Windows.Forms.MethodInvoker(delegate{
FilterLookup(sender);
}));
}
--------------------------------------------------------------------------------------------------
请C#大侠帮小弟将上述代码翻译成VB.Net的,谢谢了!
最主要是下面(private void gridLookUpEdit1_EditValueChanging)那段。
不要用工具转换的,因为我也用过此类工具,错误太多!
非常感谢! 展开
2个回答
展开全部
Private Sub gridLookUpEdit1_Popup(ByVal sender As Object, ByVal e As EventArgs)
FilterLookup(sender)
End Sub
Private Sub FilterLookup(ByVal sender As Object)
Text += " ! "
Dim edit As GridLookUpEdit = TryCast(sender, GridLookUpEdit)
Dim gridView As GridView = TryCast(edit.Properties.View, GridView)
Dim fi As FieldInfo = gridView.[GetType]().GetField("extraFilter", BindingFlags.NonPublic Or BindingFlags.Instance)
Text = edit.AutoSearchText
Dim op1 As New BinaryOperator("Code", edit.AutoSearchText + "%", BinaryOperatorType.[Like])
Dim op2 As New BinaryOperator("Name", edit.AutoSearchText + "%", BinaryOperatorType.[Like])
Dim filterCondition As String = New GroupOperator(GroupOperatorType.[Or], New CriteriaOperator() {op1, op2}).ToString()
fi.SetValue(gridView, filterCondition)
Dim mi As MethodInfo = gridView.[GetType]().GetMethod("ApplyColumnsFilterEx", BindingFlags.NonPublic Or BindingFlags.Instance)
mi.Invoke(gridView, Nothing)
End Sub
Private Sub gridLookUpEdit1_EditValueChanging(ByVal sender As Object, ByVal e As ChangingEventArgs)
Me.BeginInvoke(New System.Windows.Forms.MethodInvoker(Function() Do FilterLookup(sender) End Function))
End Sub
FilterLookup(sender)
End Sub
Private Sub FilterLookup(ByVal sender As Object)
Text += " ! "
Dim edit As GridLookUpEdit = TryCast(sender, GridLookUpEdit)
Dim gridView As GridView = TryCast(edit.Properties.View, GridView)
Dim fi As FieldInfo = gridView.[GetType]().GetField("extraFilter", BindingFlags.NonPublic Or BindingFlags.Instance)
Text = edit.AutoSearchText
Dim op1 As New BinaryOperator("Code", edit.AutoSearchText + "%", BinaryOperatorType.[Like])
Dim op2 As New BinaryOperator("Name", edit.AutoSearchText + "%", BinaryOperatorType.[Like])
Dim filterCondition As String = New GroupOperator(GroupOperatorType.[Or], New CriteriaOperator() {op1, op2}).ToString()
fi.SetValue(gridView, filterCondition)
Dim mi As MethodInfo = gridView.[GetType]().GetMethod("ApplyColumnsFilterEx", BindingFlags.NonPublic Or BindingFlags.Instance)
mi.Invoke(gridView, Nothing)
End Sub
Private Sub gridLookUpEdit1_EditValueChanging(ByVal sender As Object, ByVal e As ChangingEventArgs)
Me.BeginInvoke(New System.Windows.Forms.MethodInvoker(Function() Do FilterLookup(sender) End Function))
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询