DataView filter not working in MDI child forms with reference to MDI parent DataSet 
Author Message
 DataView filter not working in MDI child forms with reference to MDI parent DataSet

For some reason, DataView filters within an MDI child form do not seem to work when applied against a referenced DataSet passed to child forms by an MDI container.

Code fragments are : (The last line is the DataView filter that does not work in child forms)

A) wbmain.cs (MDI Parent)

private WhiteBoard.Windows.Client.WebServices.WhiteBoardDS whiteBoardDS1;

private void wbmain_Load(object sender, System.EventArgs e)

{

      setCurrentForm(new frmMain(whiteBoardDS1)); // DS reference passed to child form

Quote:
}

private void setCurrentForm(Form f)

{

      if (f==null) return;

      if (f==currForm) return;

      f.TopLevel = false;

      f.MdiParent = this;

      pnlMain.Controls.AddRange(new System.Windows.Forms.Control[] { f });

      f.Dock = DockStyle.Fill;

      f.BringToFront();            

      f.Show();

      if (currForm != null)

      {

            currForm.Close();

            pnlMain.Controls.Remove(currForm);

      }

      currForm = f;

Quote:
}

private void GetWhiteBoardDS() // Fired on menu and toolbar events

{

      Service1 s1 = new WhiteBoard.Windows.Client.WebServices.Service1();

      try

      {

            this.Cursor = Cursors.WaitCursor;

            whiteBoardDS1.Merge(s1.GetWhiteBoardDS());

      }

      catch (Exception ex)

      {

            MessageBox.Show(ex.Message);

            MessageBox.Show("Data will be loaded from local cache");

            whiteBoardDS1.ReadXml("c:\\data\\whiteboard.xml");

      }

      finally

      {

            this.Cursor = Cursors.Default;

            frmBase activeChild = (frmBase) currForm;

            if (activeChild != null)

            {

                  activeChild.AfterWhiteboardDSFill();

            }

      }

Quote:
}

B) frmBase.cs (base form for all MDI child forms)

public class frmBase : System.Windows.Forms.Form

{

      protected WhiteBoard.Windows.Client.WebServices.WhiteBoardDS whiteBoardDS1;

      protected System.Data.DataView vCompany;

      private System.ComponentModel.Container components = null;

      public frmBase()

      {

            InitializeComponent();

      }

      // [CODE SNIPPED FOR BREVITY]

      public virtual void SaveWhiteBoardDS(){}

      public virtual void AfterWhiteboardDSFill(){}

Quote:
}

C) frmMain.cs (primary child form within MDI container -- inherited from frmBase)

public class frmMain : WhiteBoard.Windows.Client.frmBase

{

      public override void AfterWhiteboardDSFill()

      {

            if (ugCompany.Rows.Count > 0)

            {

                  ugCompany.Rows[0].Activate();

            }

            BuildValueLists();

      }

      public frmMain(WhiteBoardDS ds)

      {

            InitializeComponent();

            whiteBoardDS1 = ds; // Reference to parent DS cached in base form

      }

      private void InitializeComponent()

      {

            this.ugCompany.DataSource = this.vCompany; // DataView bound to grid

      }

      private void SetCompanyTypeFilter() // DS previously filled.

      {

            string s1 = "Type = ''";

            if (cbDeveloper.Checked && cbDesignCenter.Checked)

                  s1 = "Type = '1' OR Type = '2'";

            else

                  if (cbDeveloper.Checked)

                  s1 = "Type = '1'";

            else

                  if (cbDesignCenter.Checked)

                  s1 = "Type = '2'";

            vCompany.Table = whiteBoardDS1.Tables["wbtCompany"];

            vCompany.RowFilter = s1; // THIS FILTER DOES NOT WORK IN CHILD!!!

      }

Quote:
}



Sun, 26 Jun 2005 01:51:38 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. DataView not working with referenced DataSet in MDI child forms

2. How develop MDI application with child forms like VB MDI and Child forms

3. How to let parent form listening MDI child Form

4. Communication between MDI Parent and MDI Child

5. MDI Forms Child getting parent Info

6. Opening a new MDI child when no MDI Child exists

7. Opening a new MDI child from a MDI Child

8. Why CoolMenuManger not working in MDI child Frames System Menu

9. How develop MDI form with child forms

10. MDI Parent/Child Question

11. Embedding controls in MDI parent forms.

12. MFC MDI Multiple Views in Separate MDI Child Windows

 

 
Powered by phpBB® Forum Software