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. .NET (Core and Framework)
  4. DataBindings, BindingContext's, CurrencyManagers etc...

DataBindings, BindingContext's, CurrencyManagers etc...

Scheduled Pinned Locked Moved .NET (Core and Framework)
databasequestionannouncement
2 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.
  • P Offline
    P Offline
    paper67
    wrote on last edited by
    #1

    Just curious. I have a master form with a DataGridView on it showing me the records of a DataTable. The same form also holds 3 buttons. (An "Insert", "Update" and "Delete" button). Clicking "Insert" I do : CustomerForm Form = new CustomerForm(m_CustomerDT.NewCustomerRow()); : if (Form.ShowDialog() == DialogResult.OK) m_CustomerDT.AddCustomerRow(Form.CustomerRow); Clicking "Update" I do : CustomerForm Form = new CustomerForm(m_CustomerDT[DataGrdVw.SelectedRows[0].Index]); : Form.ShowDialog(); In the CustomerForm_Load handler I initialize my CustomerForm controls like : if (!m_CustomerRow.IsNull("LastName")) { LastNameTxtBx.Text = m_CustomerRow.LastName; : } In the OKButton_Click handler I do the opposite, saving the values back in the DataRow. Everything works fine that way, but is it the correct way to go ?? Shouldn't I use DataBindings, BindingContext's, CurrencyManagers etc ... If so, why and how should that translate for my context ?

    R 1 Reply Last reply
    0
    • P paper67

      Just curious. I have a master form with a DataGridView on it showing me the records of a DataTable. The same form also holds 3 buttons. (An "Insert", "Update" and "Delete" button). Clicking "Insert" I do : CustomerForm Form = new CustomerForm(m_CustomerDT.NewCustomerRow()); : if (Form.ShowDialog() == DialogResult.OK) m_CustomerDT.AddCustomerRow(Form.CustomerRow); Clicking "Update" I do : CustomerForm Form = new CustomerForm(m_CustomerDT[DataGrdVw.SelectedRows[0].Index]); : Form.ShowDialog(); In the CustomerForm_Load handler I initialize my CustomerForm controls like : if (!m_CustomerRow.IsNull("LastName")) { LastNameTxtBx.Text = m_CustomerRow.LastName; : } In the OKButton_Click handler I do the opposite, saving the values back in the DataRow. Everything works fine that way, but is it the correct way to go ?? Shouldn't I use DataBindings, BindingContext's, CurrencyManagers etc ... If so, why and how should that translate for my context ?

      R Offline
      R Offline
      RobCroll
      wrote on last edited by
      #2

      I'd say in a Windows Forms project that is perfectly acceptable and gives you the control you need to validate the data entered. In WPF however you really want to take advantage of the binding model within WPF and MVVM. I have heard that people are successfully implementing MVVM in Windows Forms which would be a nice way to go.

      "You get that on the big jobs."

      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