Working with AutoFilters in ListObject? RRS feed

  • Question

  • Hi!

    I've bound a typed dataset to a Excel table (Range formatted as Table):

    public DataSet1 SheetContent = new DataSet1();
    ListObject ExcelAdapter;
    readonly String TableName = "Nutzerdaten";
    private void Tabelle2_Startup(object sender, System.EventArgs e)
    	if (!Controls.Contains("Nutzerdaten"))
    		ExcelAdapter = this.Controls.AddListObject(Range["A1:C1000"], TableName);
    		ExcelAdapter.TableStyle = "TableStyleMedium10";
    		ExcelAdapter = (ListObject)Controls[TableName];
    	ExcelAdapter.ShowAutoFilter = true;
    	ExcelAdapter.ShowHeaders = true;
    	ExcelAdapter.AutoSetDataBoundColumnHeaders = true;
    	ExcelAdapter.SetDataBinding(SheetContent, TableName, "Name", "Wert", "Datum");

    So fa so good. But now I'd like to access the autofilters at the column headers and set the filters to sensible values (depending on data, user input etc.).

    Does anyone know how to do this?

    Lots of Greetings!


    Monday, August 27, 2012 11:39 AM


  • Hi Volker,

    Thank you for posting in the MSDN Forum.

    It's based on my experience that you may look for the Range.AutoFilter Method to access the autofilter in the range. In terms of this method, you can filter a list by setting the Criteria variable to appropriate value depending on data, user input etc.

    Hope this helps. If I misunderstand you , please feel free to let me know.

    Best Regards, 

    Leo_Gao [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Hetzi Tuesday, August 28, 2012 10:37 AM
    Tuesday, August 28, 2012 7:08 AM