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. Related value in Datagridviewcolumn

Related value in Datagridviewcolumn

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestion
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
    Sergiev
    wrote on last edited by
    #1

    Dear all, upon developing data entry project I've faced a problem and I still can't figure out the solution. Simplifying the matter, lets say that the the user enters the ID value and should get the decription in another column (DataGridViewTextbox) in the same datagridview. The description column should get updated immediately after the value of the ID column is changed. The scenario is very close to classical master/detail form except that the detail should be displayed into the same control. I had particullar success when bound the datagridview control to dataset relation, but the form didn't work well when inserting new rows. Can you provide me with brief advice or a link? Kind regards,

    A 1 Reply Last reply
    0
    • S Sergiev

      Dear all, upon developing data entry project I've faced a problem and I still can't figure out the solution. Simplifying the matter, lets say that the the user enters the ID value and should get the decription in another column (DataGridViewTextbox) in the same datagridview. The description column should get updated immediately after the value of the ID column is changed. The scenario is very close to classical master/detail form except that the detail should be displayed into the same control. I had particullar success when bound the datagridview control to dataset relation, but the form didn't work well when inserting new rows. Can you provide me with brief advice or a link? Kind regards,

      A Offline
      A Offline
      amit k mistry
      wrote on last edited by
      #2

      I don't get exatly what would you like to explain but as per my understanding this may be helpful to you if it didn't works for you. Let me know I can help you out with other way. http://www.progtalk.com/ViewArticle.aspx?ArticleID=54[^]

      S 1 Reply Last reply
      0
      • A amit k mistry

        I don't get exatly what would you like to explain but as per my understanding this may be helpful to you if it didn't works for you. Let me know I can help you out with other way. http://www.progtalk.com/ViewArticle.aspx?ArticleID=54[^]

        S Offline
        S Offline
        Sergiev
        wrote on last edited by
        #3

        Thank you very much for your reply! I will take a look. Anyway I will try to clarify myself by pseudo-code. Consider DB with two tables: table "payments" with the following structure: "p_id" int, "price" int, "empl_id" int and "employees": "empl_id" int, "empl_name" varchar /* this I want to get later */ It is not difficult to bind the DataGridView control to the "payments" table. In the form I define the following columns (binding them to corresponding columns in data source): datagridview.Columns("pay_id").DataPropertyName = "payments"."p_id" datagridview.Columns("price").DataPropertyName = "payments"."price" datagridview.Columns("empl_id").DataPropertyName = "payments"."empl_id" And here is it, I want to have a column which displays the employee's name taking it from table "employees". Something like: datagridview.Columns("empl_name").DataPropertyName = "employees"."empl_name" This column should refresh every time the user changes the value of datagridview.Columns("empl_id") providing him with the name of the employee. But there is no way (at least I don't know how) to define another data source for DataGridViewTextBox column. May be I need to populate manually the cell with the employee's name fetching it from dataset relation. Previously I hadn't used .NET for data entry forms which is my primary fields so I am not very certain about its classes and their properties. Thanks and regards,

        I 1 Reply Last reply
        0
        • S Sergiev

          Thank you very much for your reply! I will take a look. Anyway I will try to clarify myself by pseudo-code. Consider DB with two tables: table "payments" with the following structure: "p_id" int, "price" int, "empl_id" int and "employees": "empl_id" int, "empl_name" varchar /* this I want to get later */ It is not difficult to bind the DataGridView control to the "payments" table. In the form I define the following columns (binding them to corresponding columns in data source): datagridview.Columns("pay_id").DataPropertyName = "payments"."p_id" datagridview.Columns("price").DataPropertyName = "payments"."price" datagridview.Columns("empl_id").DataPropertyName = "payments"."empl_id" And here is it, I want to have a column which displays the employee's name taking it from table "employees". Something like: datagridview.Columns("empl_name").DataPropertyName = "employees"."empl_name" This column should refresh every time the user changes the value of datagridview.Columns("empl_id") providing him with the name of the employee. But there is no way (at least I don't know how) to define another data source for DataGridViewTextBox column. May be I need to populate manually the cell with the employee's name fetching it from dataset relation. Previously I hadn't used .NET for data entry forms which is my primary fields so I am not very certain about its classes and their properties. Thanks and regards,

          I Offline
          I Offline
          Infarkt
          wrote on last edited by
          #4

          you can use DataGridViewComboBox column instead of DataGridViewTextBoxColumn to show employee's name. Example: datagridview.Columns("empl_name").DisplayMember="empl_name" datagridview.Columns("empl_name").ValueMember ="empl_id" datagridview.Columns("empl_name").DataSource ="employees" datagridview.Columns("empl_name").DataPropertyName="payments"."p_id" datagridview.Columns("empl_name").DisplayStyle=Nothing

          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