DataView not working with referenced DataSet in MDI child forms 
Author Message
 DataView not working with referenced DataSet in MDI child forms

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

Code fragments are: (The last line is the one that does not work in a child
form)

A) wbmain.cs: (MDI Container)

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

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

{

      setCurrentForm(new frmMain(whiteBoardDS1)); // Reference to Web
Servicess accessed DataSet passed to child forms

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 from 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;

      protected System.Data.DataView vContact;

      /// <summary>

      /// Required designer variable.

      /// </summary>

      private System.ComponentModel.Container components = null;

      public frmBase()

      {

            //

            // Required for Windows Form Designer support

            //

            InitializeComponent();

            //

            // TODO: Add any constructor code after InitializeComponent call

            //

      }

      // ADDITIONAL 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

{

    private void InitializeComponent()
    {

          //

          // ugCompany  (This is the grid that DataView filters are applied

          //

          this.ugCompany.DataSource = this.vCompany;

    }

    public frmMain(WhiteBoardDS ds)

    {

          // This call is required by the Windows Form Designer.

          InitializeComponent();

          // TODO: Add any initialization after the InitializeComponent call

          whiteBoardDS1 = ds; // Reference to parent DataSet cached

    }

    private void SetCompanyTypeFilter()

    {

          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 DOES NOT WORK!!!

    }

Quote:
}



Sun, 26 Jun 2005 00:31:09 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. DataView filter not working in MDI child forms with reference to MDI parent DataSet

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

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

4. How develop MDI form with child forms

5. How to let parent form listening MDI child Form

6. DataSet or DataView?

7. DataGrid bound to DataSet or DataView?: AllowNew, AllowDelete

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

9. Opening a new MDI child from a MDI Child

10. MDI child form disables all its objets?

11. MDI duplicate child form problem.

12. MDI Forms Child getting parent Info

 

 
Powered by phpBB® Forum Software