Related value in Datagridviewcolumn
-
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,
-
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,
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[^]
-
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[^]
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,
-
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,
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