Quaneu
2015-05-22T07:39:17Z
Hello together,

i have a question about the AutoFilterManager similar to Other Post .

I created a UserControl with one iGrid Grid and one iGridAutoFiltermanger. The Property Grid in iGridAutoFiltermanger is set and the event CreateColAutoFilter is registered. But when i add columns in the Designer the event is fired before you can register it, because the event is fired when AddRange() is called in the Designer.cs.

Is there a other option to set the AutoFilterManager not for all columns that added in Designer?

With best regards
Quaneu

Igor/10Tec
2015-05-22T17:57:12Z
What exactly problem do you have? Do you want to skip your CreateColAutoFilter event handler method for columns created at design time?

Can you prepare and send a sample project to our support service?

If I understand your problem properly, I can suggest a quick workaround. You can attach the event handler method in your custom code in the UserControl's constructor or its Load event - after the initial design-time set of columns have been added.
Quaneu
2015-05-26T07:10:42Z
Quote:

What exactly problem do you have?


I want to use the VS designer to add columns but as an example the third column should not has an filter. This is not possible if i attach the event CreateColAutoFilter. Because the designer create follwing code:


			// 
			// _iGrid
			// 
			iGColPattern1.CellStyle = this._iGridCol0CellStyle;
			iGColPattern1.ColHdrStyle = this._iGridCol0ColHdrStyle;
			iGColPattern1.Text = "A";
			iGColPattern2.CellStyle = this._iGridCol1CellStyle;
			iGColPattern2.ColHdrStyle = this._iGridCol1ColHdrStyle;
			iGColPattern2.Text = "B";
			iGColPattern3.CellStyle = this._iGridCol2CellStyle;
			iGColPattern3.ColHdrStyle = this._iGridCol2ColHdrStyle;
			iGColPattern3.Key = "_columnC";
			iGColPattern3.Text = "C";
			iGColPattern4.CellStyle = this._iGridCol3CellStyle;
			iGColPattern4.ColHdrStyle = this._iGridCol3ColHdrStyle;
			iGColPattern4.Text = "D";
			this._iGrid.Cols.AddRange(new TenTec.Windows.iGridLib.iGColPattern[] {
            iGColPattern1,
            iGColPattern2,
            iGColPattern3,
            iGColPattern4});
			this._iGrid.DefaultCol.CellStyle = this.iGrid1DefaultCellStyle;
			this._iGrid.DefaultCol.ColHdrStyle = this.iGrid1DefaultColHdrStyle;
			this._iGrid.Dock = System.Windows.Forms.DockStyle.Fill;
			this._iGrid.Header.Height = 20;
			this._iGrid.Location = new System.Drawing.Point(0, 0);
			this._iGrid.Name = "_iGrid";
			this._iGrid.Size = new System.Drawing.Size(553, 524);
			this._iGrid.TabIndex = 0;
			// 
			// _iGAutoFilterManager
			//
			this._iGAutoFilterManager.Grid = this._iGrid; 
			this._iGAutoFilterManager.CreateColAutoFilter += new TenTec.Windows.iGridLib.Filtering.iGCreateColAutoFilterEventHandler(this._iGAutoFilterManager_CreateColAutoFilter);

this._iGrid.Cols.AddRange(new TenTec.Windows.iGridLib.iGColPattern[] {
            iGColPattern1,
            iGColPattern2,
            iGColPattern3,
            iGColPattern4});

Would fire the event CreateColAutoFilter but the event comes after AddRange().


Quote:

Can you prepare and send a sample project to our support service?


Yes i can.


Sorry for my bad english.
Igor/10Tec
2015-05-27T06:30:08Z
No problem with your English - I understood your task properly.

As I said, you can solve your problem by attaching the AFM in code after the WinForms Designer's code has been executed.

In the case of the classic brand new WinForms application the solution can look like this:

public partial class Form1 : Form
{
  public Form1()
  {
    InitializeComponent();
    iGAutoFilterManager1.Grid = iGrid1;
  }

  private void iGAutoFilterManager1_CreateColAutoFilter(object sender, TenTec.Windows.iGridLib.Filtering.iGCreateColAutoFilterEventArgs e)
  {
    e.DoDefault = (e.ColIndex != 2);
  }
}

You can even assign the event handler method in the Property Editor - just don't assign the Grid property there.