Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Update datagrid in a MDI child from a MDI child!!!URGENT HELP REQUIRED!!!

Update datagrid in a MDI child from a MDI child!!!URGENT HELP REQUIRED!!!

Scheduled Pinned Locked Moved C#
databasegraphicsdockerhelpannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GianlucaSeno
    wrote on last edited by
    #1

    In brief...I've a MDI application with this MDI childs(at the moment all MDI childs are closed): 1)MDIFORM (MDI container) 2)FORM1 (MDI form child) 3)FORM2 (MDI form child) I press a menu on MDIFORM that opens FORM1. In FORM1 there is a texbox. On keyPress event of textbox I write in a MSAccess table what I'm writing in the textbox. On Load event of FORM1 I open FORM2 where is a datagrid. The code is: public class FORM1: System.Windows.Forms.Form { private FORM2 form2=null; private void FORM1_Load(object sender, System.EventArgs e) { if (this.form2==null) { this.form2=new FORM2(); this.form2.MdiParent=this.MdiParent; } this.form2.Show(); } private void InsertString(object sender, System.Windows.Forms.KeyPressEventArgs e) { // -- INSERT DB } } In FORM2 I've a datagrid where I show results written before in last MSAccess table.The code is this: public class FORM2 : System.Windows.Forms.Form { private System.ComponentModel.Container components = null; private System.Windows.Forms.DataGrid dataPreResult; public FORM2() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code private void InitializeComponent() { this.dataPreResult = new System.Windows.Forms.DataGrid(); ((System.ComponentModel.ISupportInitialize)(this.dataPreResult)).BeginInit(); this.SuspendLayout(); // // dataPreResult // this.dataPreResult.AllowSorting = false; this.dataPreResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.dataPreResult.DataMember = ""; this.dataPreResult.Dock = System.Windows.Forms.DockStyle.Fill; this.dataPreResult.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.dataPreResult.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataPreResult.Location = new System.Drawing.Point(0, 0); this.dataPreResult.Name = "dataPreResult"; this.dataPreResult.ReadOnly = true; this.dataPreResult.RowHeaderWidth = 10; this.dataPreResult.Si

    B 1 Reply Last reply
    0
    • G GianlucaSeno

      In brief...I've a MDI application with this MDI childs(at the moment all MDI childs are closed): 1)MDIFORM (MDI container) 2)FORM1 (MDI form child) 3)FORM2 (MDI form child) I press a menu on MDIFORM that opens FORM1. In FORM1 there is a texbox. On keyPress event of textbox I write in a MSAccess table what I'm writing in the textbox. On Load event of FORM1 I open FORM2 where is a datagrid. The code is: public class FORM1: System.Windows.Forms.Form { private FORM2 form2=null; private void FORM1_Load(object sender, System.EventArgs e) { if (this.form2==null) { this.form2=new FORM2(); this.form2.MdiParent=this.MdiParent; } this.form2.Show(); } private void InsertString(object sender, System.Windows.Forms.KeyPressEventArgs e) { // -- INSERT DB } } In FORM2 I've a datagrid where I show results written before in last MSAccess table.The code is this: public class FORM2 : System.Windows.Forms.Form { private System.ComponentModel.Container components = null; private System.Windows.Forms.DataGrid dataPreResult; public FORM2() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code private void InitializeComponent() { this.dataPreResult = new System.Windows.Forms.DataGrid(); ((System.ComponentModel.ISupportInitialize)(this.dataPreResult)).BeginInit(); this.SuspendLayout(); // // dataPreResult // this.dataPreResult.AllowSorting = false; this.dataPreResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.dataPreResult.DataMember = ""; this.dataPreResult.Dock = System.Windows.Forms.DockStyle.Fill; this.dataPreResult.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.dataPreResult.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataPreResult.Location = new System.Drawing.Point(0, 0); this.dataPreResult.Name = "dataPreResult"; this.dataPreResult.ReadOnly = true; this.dataPreResult.RowHeaderWidth = 10; this.dataPreResult.Si

      B Offline
      B Offline
      Bojan Rajkovic
      wrote on last edited by
      #2

      Uh...What you need to do is maybe set a timer in form 2 to refresh the data in the datagrid.. I have an app that I do something similar in, and all you need to do is call ReadResults() and do dataPreResult.Invalidate() (to make sure that it gets redrawn) every so often..I'm not 100% sure on that, but it should work. Here's the relevant code: **Timer updateDataGrid = new Timer();** // add this to your object declarations public FORM2() { InitializeComponent(); **updateDataGrid.Interval = 60*1000; updateDataGrid.Tick += new EventHandler(doUpdate); updateDataGrid.Start();** // add the above 3 lines in the constructor to set the interval, the handler for the timer firing and to start it. updating every minute seems like a good time, but you can change that } private void doUpdate(object sender, EventArgs e) { ReadResults(); dataPreResult.Invalidate(); }

      G 1 Reply Last reply
      0
      • B Bojan Rajkovic

        Uh...What you need to do is maybe set a timer in form 2 to refresh the data in the datagrid.. I have an app that I do something similar in, and all you need to do is call ReadResults() and do dataPreResult.Invalidate() (to make sure that it gets redrawn) every so often..I'm not 100% sure on that, but it should work. Here's the relevant code: **Timer updateDataGrid = new Timer();** // add this to your object declarations public FORM2() { InitializeComponent(); **updateDataGrid.Interval = 60*1000; updateDataGrid.Tick += new EventHandler(doUpdate); updateDataGrid.Start();** // add the above 3 lines in the constructor to set the interval, the handler for the timer firing and to start it. updating every minute seems like a good time, but you can change that } private void doUpdate(object sender, EventArgs e) { ReadResults(); dataPreResult.Invalidate(); }

        G Offline
        G Offline
        GianlucaSeno
        wrote on last edited by
        #3

        No way...nothing happens...:sigh:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups