问题描述
私有 void button1_Click(对象发件人,EventArgs e) { 如果(ch1.Checked& ch2.Checked& ch3.Checked) { 字符串过滤器= 字符串 .Format(" ACCentrala = \'" +(centrala.Text + " \'")); 过滤器+ = " AND" ; 过滤器+ = 字符串 .Format(" ACTelefon = \' " +(lokal.Text + " \'")); 过滤器+ = " AND" ; 过滤器+ = 字符串 .Format(" ACPloca = \' " +(ploca.Text + " \'")); 此 .istorijaBS.Filter =过滤器; } }
我需要上面代码的帮助,我有三个文本框text1,text2和text3,三个复选框check1,check2和check3.当CHECK1检查text1为有源滤波器...等等.但是在这段代码中,当我检查所有3个文本框以进行全部3个文本框过滤时,它不起作用吗? "code-keyword">字符串 filter1 = 字符串 .Format(" ACCentrala = \"{0} \"",centrala.Text);字符串 filter2 = 字符串 .Format(" ACTelefon = \"{0} \"",lokal.Text);字符串 filter3 = 字符串 .Format(" ACPloca = \"{0} \"",ploca.Text);字符串 filter = " " ;如果(已选中ch1){ filter = filter1;}如果(已选中ch2){ 如果(!string.IsNullOrEmpty(filter)) { 过滤器+ = " AND" ; } 过滤器+ = filter2;}如果(ch3.已选中){ 如果(!string.IsNullOrEmpty(filter)) { 过滤器+ = " AND" ; } 过滤器+ = filter3;}此 .istorijaBS.Filter =过滤器;
private void button1_Click(object sender, EventArgs e) { if (ch1.Checked && ch2.Checked && ch3.Checked) { string filter = string.Format("ACCentrala = \'" + (centrala.Text + "\'")); filter += " AND "; filter += string.Format("ACTelefon = \'" + (lokal.Text + "\'")); filter += " AND "; filter += string.Format("ACPloca = \'" + (ploca.Text + "\'")); this.istorijaBS.Filter = filter; } }
I need help with code above, I have three textboxes text1, text2 and text3, 3 checkboxes check1, check2 and check3. when check1 is checked text1 is active filter...and so on. but in this code when I check all 3 of them for filtering with all 3 textboxes it doesnt work?
这篇关于多个过滤器不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!