programatically setting AutoFilter

Hello NOOB here,


I'm using a Form with two textbox autofilters, one that has a "Contains" filter, and the other that has a "NotContains" filter, I need them to work in an either/or fashion. (If I'm not using one - use the other...)

(The reason I'm doing this is because I can't figure out how to switch one TextBox contains filter to a contains or not contains filter, so I'm trying to use two and then turn one or the other one on or off)


Q1) Can I use the detail control feature to turn a textbox AutoFilter on/off (what I have in the picture doesn't seem to work)?


Q2)How can I program the FilterData property of the AutoFilter to Contains or NotContains?

What all has to be set/programmed to programatically use the AutoFilter. (The manual doesn't give an example or detail what is needed).


This is what I've tried and it does not work (when a radio button is clicked, fill the TextBox1 with this "mai" text and then set the autofilter to true and use these details to programmatically set the autofilte:


 private void RadioButton2_Click(object sender, EventArgs e)

 {

 TextBox1.Text = "mai"; //this is the text I'm trying to filter (contains or notcontains)

 TextBox1.AutoFilter = true;  

 TextBox1.DataColumn = ((String)Report.GetColumnValue("RSRList.SRI"));

 TextBox1.FilterOperation = "NotContains" ; // I know this doesn't work, this is more of a filler

//what else should be set?

 }


private void RadioButton3_Click(object sender, EventArgs e)

  { 

//below is the original way I was trying to toggle between the TextBox filters (I had RadioButton2 setup in reverse)

   TextBox2.Text = "mai"; //this is the text I'm trying to filter (contains or notcontains)

   //TextBox2.AutoFilter = true;  

   //TextBox2.FilterData();

   TextBox1.Text = "";

   //TextBox1.AutoFilter = false;

  }

   

  private void btnOk_Click(object sender, EventArgs e)

  {

   if(RadioButton1.Checked = true){

    TextBox1.AutoFilter = false;

    TextBox2.AutoFilter = false;

   }

   if(RadioButton2.Checked = true){

    TextBox2.AutoFilter = false;

   }

   if(RadioButton3.Checked = true){

    TextBox1.AutoFilter = false;

   }

    

  }

Comments

  •  >>TextBox1.DataColumn = ((String)Report.GetColumnValue("RSRList.SRI"));

    TextBox1.DataColumn = "Exercise.Region"; =>tablename.fieldname


    >>TextBox1.FilterOperation = "NotContains" ; // I know this doesn't work, this is more of a filler

    //what else should be set?

    TextBox1.FilterOperation = FastReport.Data.FilterOperation.NotContains;

  • Thank you for the help!

    One more question.

    I've been using a message box after the form OK button click to see/confirm how my different textbox filters are set.

    Is there a way see how the whole AutoFilter is set for the report before the report is created?

    (I'm using FastReport inside of a 3rd party software where they've plumbed in FR as their reporting tool - but I don't have any debugging features other than an error message box and message boxes that I can get to pop up with dialogue.)

Leave a Comment