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. hi, c# forms

hi, c# forms

Scheduled Pinned Locked Moved C#
csharpdatabasehelpquestionannouncement
4 Posts 3 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.
  • S Offline
    S Offline
    sopho24
    wrote on last edited by
    #1

    I'm working with 2 forms Form1 and Form2. Logically Form1 is a parent form and Form2 is where a data input is requested from user. When Form2 opened upon Form1, user enters some data and Form2 exits. When Form2 exits, the datagrid in Form1 must be updated with new value. I'm trying to update datagrid with a code inside Form2.cs : //inside Form2.cs, a method of click of a button ...sql operations bla bla Form1 f = (Form1)this.owner; f.fillDataGrid(); // this method belongs to Form1 this.Close(); But..... Datagrid doesn't always update, sometimes works. Any idea? A non-smart way I tried, to use focus event; but it doesn't focus anyway. Plz help may the force be with you, always

    K F 2 Replies Last reply
    0
    • S sopho24

      I'm working with 2 forms Form1 and Form2. Logically Form1 is a parent form and Form2 is where a data input is requested from user. When Form2 opened upon Form1, user enters some data and Form2 exits. When Form2 exits, the datagrid in Form1 must be updated with new value. I'm trying to update datagrid with a code inside Form2.cs : //inside Form2.cs, a method of click of a button ...sql operations bla bla Form1 f = (Form1)this.owner; f.fillDataGrid(); // this method belongs to Form1 this.Close(); But..... Datagrid doesn't always update, sometimes works. Any idea? A non-smart way I tried, to use focus event; but it doesn't focus anyway. Plz help may the force be with you, always

      K Offline
      K Offline
      karam chandrabose
      wrote on last edited by
      #2

      Hi, in this scenario, define your entity object as a class, let Form1 have an static object of that class, in form two set the value for the static instance, then when u go back to form1 , do the data binding.. like this.. Form1 { public static CEntity objEntity; someclick() { Form2.showDialog() Datagrid.databind(objEntity) } } CEntity { Public string column1; Public string column2; } Form2 { someevent() { Form1.objEntity.column1 = textbox1.Text; Form1.objEntity.column2 = textbox2.Text; } } Cheers

      1 Reply Last reply
      0
      • S sopho24

        I'm working with 2 forms Form1 and Form2. Logically Form1 is a parent form and Form2 is where a data input is requested from user. When Form2 opened upon Form1, user enters some data and Form2 exits. When Form2 exits, the datagrid in Form1 must be updated with new value. I'm trying to update datagrid with a code inside Form2.cs : //inside Form2.cs, a method of click of a button ...sql operations bla bla Form1 f = (Form1)this.owner; f.fillDataGrid(); // this method belongs to Form1 this.Close(); But..... Datagrid doesn't always update, sometimes works. Any idea? A non-smart way I tried, to use focus event; but it doesn't focus anyway. Plz help may the force be with you, always

        F Offline
        F Offline
        Flysocket
        wrote on last edited by
        #3

        Form1 f = (Form1)this.owner; f.fillDataGrid(); // this method belongs to Form1 this.Close(); if these code wrote in the form2's closing or closed event?

        I want to make some friends here

        S 1 Reply Last reply
        0
        • F Flysocket

          Form1 f = (Form1)this.owner; f.fillDataGrid(); // this method belongs to Form1 this.Close(); if these code wrote in the form2's closing or closed event?

          I want to make some friends here

          S Offline
          S Offline
          sopho24
          wrote on last edited by
          #4

          yes, it's written in closed event in a different solution..

          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