Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > How do I get the right information into my datagridview
 

How do I get the right information into my datagridview

I am trying to write a program for my work (I am a dispatcher for a logging firm) and I need to record the amount of wood our crews have on their skidsites and send trucks to pick up the wood and take it to our customers. I am using SQL.

So far I have created tables, for crews, customers, trucks, wood types (Products) and Logstocks (the amount of wood on each crews skidsite.

I have created forms where I can add/update the truck numbers, crews, suppliers, woodtypes etc and they all work fine. Now I am onto the stocks form, and this is where I am a bit stuck.

In my Stocks table I have the following rows: SupplierID, ProductID, LoadsInStock, LoadsPlanned and LoadsAvaialble. The SupplierID and ProductID are foreign keys linked the the appropriate tables.

On My form I have dragged from my datasources the SupplierID as a ComboBox so that the user can select which crew they are adding the stocks for and the Stocks table as a DatagridView, with the SupplierID column not visable

My question is this �all crews have the same products, therefore I want the Woodtypes (ProductName) from the products table to always show in the ProductID column - the other 3 columns will change for each crew depending on how much wood they have. The LoadsInStock column will be entered manually when they call in their loads, the LoadsPlanned will show when a truck is sent for a load (this I still have to work out when I work on the loads carted part of the program) and the LoadsAvailable will show what is left to be picked up ie LoadsInStock - LoadsPlanned = LoadsAvailable this I think I can do with a query.

Any help with this would really be appreciated as I only have this to work out and then how to record the loads carted by the trucks and I think I am just about there.

Diane

  • Moved byMartin Xie - MSFTMSFTThursday, August 27, 2009 11:11 AMMove it to DataBinding Controls Forum for better support. (From:Visual Basic Express Edition)
  •  
DianeJ  Tuesday, August 25, 2009 10:24 PM

Hi DianeJ,

You said: all crews have the same products, therefore I want the Woodtypes (ProductName) from the products table to always show in the ProductID column.
To solve this issue, we can add a DataGridViewComboBoxColumn named productCol to the DataGridView. Then we need to set the DataSource property of productCol to the
Products DataTable, set the DisplayMember to ProductName and set ValueMember to ProductId. You can get more information about DataGridViewComboBoxColumn from:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcolumn.aspx.

You also said: the other 3 columns will change for each crew depending on how much wood they have. The LoadsInStock column will be entered manually when they call in their loads, the LoadsPlanned will show when a truck is sent for a load (this I still have to work out when I work on the loads carted part of the program) and the LoadsAvailable will show what is left to be picked up ie LoadsInStock - LoadsPlanned = LoadsAvailable this I think I can do with a query.
Since I am not familiar with this kind of logic, I can only give you some technology suggestions. These are my ideas:

1. Filter data: We can set the Filter property of the BindingSource which binds to the DataGridView to a condition string, such as "SupplierID = 1".

2. Update data to database: This would be a little complicated. We need to update the data in other tables according to the data in stokes and then use their DataAdapters to update data to database.

Let me know if this helps.
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Friday, August 28, 2009 12:33 PM

Hi DianeJ,

You said: all crews have the same products, therefore I want the Woodtypes (ProductName) from the products table to always show in the ProductID column.
To solve this issue, we can add a DataGridViewComboBoxColumn named productCol to the DataGridView. Then we need to set the DataSource property of productCol to the
Products DataTable, set the DisplayMember to ProductName and set ValueMember to ProductId. You can get more information about DataGridViewComboBoxColumn from:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcolumn.aspx.

You also said: the other 3 columns will change for each crew depending on how much wood they have. The LoadsInStock column will be entered manually when they call in their loads, the LoadsPlanned will show when a truck is sent for a load (this I still have to work out when I work on the loads carted part of the program) and the LoadsAvailable will show what is left to be picked up ie LoadsInStock - LoadsPlanned = LoadsAvailable this I think I can do with a query.
Since I am not familiar with this kind of logic, I can only give you some technology suggestions. These are my ideas:

1. Filter data: We can set the Filter property of the BindingSource which binds to the DataGridView to a condition string, such as "SupplierID = 1".

2. Update data to database: This would be a little complicated. We need to update the data in other tables according to the data in stokes and then use their DataAdapters to update data to database.

Let me know if this helps.
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Friday, August 28, 2009 12:33 PM
Hi DianeJ,

Could you please let me know if my reply helps?

Regards,
Aland Li

Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Monday, August 31, 2009 3:25 AM

You can use google to search for other answers

Custom Search

More Threads

• Data binding and ICustomTypeDescriptor
• Datagridview combobox Deafult Value
• Prevent columns in winforms datagrid from scrolling
• bounded datagridview, acceptChanges, and row color
• load combo from stored procedure
• how do i export records in my datagridview in an excel or a pdf file - need urgent help
• Problem with focus on tab control
• How do i sort unbound data in a DataGridView ?
• Auto number not showing in Datagridview
• Adding controls to the toolbox.