I have an vb.net windows application that has some values which i entered through textbox. And two datagridviews, in that in first datagridview ,when i enter values in all columns, i have a formula which takes value from Textboxes and DatagridView1 column values. These calculated value should display in second datagridview columns. For this i tried two ways but both showing problem. First try:
//First Datagridview -LogCalcEnter , Second Datagrid - LogCalValue
Private Sub LogCalcEnter_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles LogCalcEnter.CellValueChanged
LogCalValue.Rows(intRow).Cells(0).Value = LogCalcEnter.Rows(iRow).Cells(0).Value * fPorCutoff.Text
LogCalValue.Rows(intRow).Cells(1).Value = LogCalcEnter.Rows(iRow).Cells(1).Value * fSWCutoff.Text
End Sub
When executing the application,before showing the form below error occurs at
Me.MainForm = Global.LogCalculation.Form1
in OnCreateMainForm().
Additional information: An error occurred creating the form. See Exception.InnerException for details. The error is: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
So i tried another option i have button in form, when i press button,then depends on number of rows in first grid view i will set the values for second datagrid. But it works if i have one row in Datagridview1. If more than one row, it shows error at second row.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oLog As New Log
oLog.sWellName = tWellname.Text
oLog.fPoroCutoff = fPorCutoff.Text
oLog.fSWCutOff = fSWCutoff.Text
oLog.fN = fN.Text
oLog.fM = fM.Text
oLog.fA = fA.Text
oLog.fRW = fRW.Text
For iRow = 0 To LogCalcEnter.Rows.Count - 1
If (Trim(LogCalcEnter.Rows(iRow).Cells(0).Value) <> "" And Trim(LogCalcEnter.Rows(iRow).Cells(1).Value) <> "" And Trim(LogCalcEnter.Rows(iRow).Cells(2).Value) <> "") Then
LogCalValue.Rows(iRow).Cells(0).Value = LogCalcEnter.Rows(iRow).Cells(0).Value * oLog.fPoroCutoff
LogCalValue.Rows(iRow).Cells(1).Value = LogCalcEnter.Rows(iRow).Cells(1).Value * oLog.fSWCutOff
LogCalValue.Rows(iRow).Cells(2).Value = LogCalcEnter.Rows(iRow).Cells(2).Value * oLog.fN
End If
Next iRow
End Sub
Actually i want the first option only. But here these two cases get failed.