Hallo Peter Thanks it works almost as expected but one problem , if i go to previous bidder and change the value , new value is not being updated or saved. how can i make it save or update as i type?
Make Datagridview Part of UI and use the input values with class object
Hallo,
I am trying figure out for more than a month but with my current knowledge it seems impossible. Currently i have a datagridview as shown in screenshot. it is a kind of template with predefined objects bound to datagridview and it is part of the UI it is always there and i have a class called Work and it is instances are bound to another datagridview where i can add more instances or remove them. Every work instance can have different set of man hour values , if user enters the new value, cost will be calculated with user value. here i want to save only the inputs from the datagrid view with my object instances. How can i do that? Any help will be much appreciated.
Public Class Form1
Public TemplateList As New List(Of Template)
Public BS_TemplateList As New BindingSource
Public WorkList As New List(Of Work)
Public BS_WorkList As New BindingSource
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TemplateList.Add(New Template With {.ID = 1, .Description = "Discription 1", .HourDefault = 1, .UnitPrice = 5})
TemplateList.Add(New Template With {.ID = 2, .Description = "Discription 2", .HourDefault = 1, .UnitPrice = 10})
TemplateList.Add(New Template With {.ID = 3, .Description = "Discription 3", .HourDefault = 1, .UnitPrice = 15})
TemplateList.Add(New Template With {.ID = 4, .Description = "Discription 4", .HourDefault = 1, .UnitPrice = 20})
BS_TemplateList.DataSource = TemplateList
DataGridView1.DataSource = BS_TemplateList
BS_WorkList.DataSource = WorkList
DataGridView2.DataSource = BS_TemplateList
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
BS_WorkList.Add(New Work With {.WorkID = 1, .Item = "Work1"})
End Sub
End class
Public Class Template
Public Property ID As Integer
Public Property Description As String
Public Property Hour As Integer?
Public Property HourDefault As Integer
Public Property UnitPrice As Integer
Public ReadOnly Property Cost As Integer
Get
If Hour > 0 Then
Return Hour * UnitPrice
Else
Return HourDefault * UnitPrice
End If
End Get
End Property
Public Property Remarks As String
End Class
Public Class Work
Public Property WorkID As Integer
Public Property Item As String
Public Property TemplateID As Integer
Public Property Hour As Integer
Public Property Remarks As String
End Class
Thanks