Home > Net >  DataGridView data extraction
DataGridView data extraction

Time:09-24

System. NullReferenceException: "the object reference not set to an instance of an object,"


Public Class FormZsz
Public Sub cmdDBInput_Click (sender As Object, As EventArgs e) Handles cmdDBInput. Click
,,,,,,,
DataGridView1. The DataSource=aa


How will the second column in the DataGridView data is assigned to in the code below ActQ


The Module ModuleCalculation
,,,,,,,,,,,,,,,,
If the Cell (SimplyCell (I). NodeIndex). Type="ZSZ" Then

ZszXH=GetZszIndex (Cell (SimplyCell (I). NodeIndex). The Name)
H (I)=Zsz (ZszXH) ActGY * 102

C (I)=Zsz (ZszXH) ActQ

CodePudding user response:

https://blog.csdn.net/hejisan/article/details/52688972

CodePudding user response:

Datagridview. Rows (I) cells (p) value

CodePudding user response:

I this is one of the Class
One is the Moudle
So write directly
Zsz (I). ActQ=DataGridView1. Rows (I) Cells (1). The Value
There is an error

CodePudding user response:

I value you, ensure rows (I) and asz (I) isnot nothing

CodePudding user response:




Mistake is such, should still pass the cords of the mistake?

CodePudding user response:

Lazy at hand in the past the datagridview bai,

Public function calculation (byval DGV as datagridview, other parameters) as a double

Zsz (I). ActQ=DGV. Rows (I) Cells (1). The Value

End the function

Call in the class

DIM P AS DOUBLE=computing (DATAGRIDVIEW1, other parameters)

CodePudding user response:

Why take from the datagridview?
In the binding of data source, isn't it better?
Unless you to write down this is the front desk,

So you want to find the corresponding rows and cells

CodePudding user response:

Because I this data source involves the production date, I need to extract a production date data calculation, so my first step to pick up the useful data, and then need to use these data to calculate

CodePudding user response:

It is hard to understand what they want...

Values in the database, and then can send the data to calculate phase of SQL well,

DataTable phase to create a calculated column also run out of things,

Don't create computed columns to a For loop computation complex operations,

-

Depending on the calculated separately into a DLL, can update algorithm??

Anyway, not very well understood,

CodePudding user response:

In your another post has been restored.
Will return again to the double integral?

The first routine,
 
Private Sub CalcColumns ()
Dim rate As Single=. 0862
Dim table As New DataTable ()

'Create the first column.
Dim priceColumn As New DataColumn ()
With priceColumn
. The DataType=System. The GetType (" System. A Decimal ")
The ColumnName="price"
The DefaultValue=https://bbs.csdn.net/topics/50
End With

'Create the second, calculated, column.
Dim taxColumn As New DataColumn ()
With taxColumn
. The DataType=System. The GetType (" System. A Decimal ")
The ColumnName="tax"
The Expression="price * 0.0862"
End With

'Create third column
Dim totalColumn As New DataColumn ()
With totalColumn
. The DataType=System. The GetType (" System. A Decimal ")
The ColumnName="total"
The Expression="price + tax"
End With

'Add columns to the DataTable
With the table. The Columns
The Add (priceColumn)
The Add (taxColumn)
The Add (totalColumn)
End With

Dim row As DataRow=table. NewRow
A table. Rows. The Add (row)
Dim view As New DataView
The Table=Table
DataGrid1. The DataSource=view
End Sub


Implementation, mainly use the DataColumn Expression attribute.


  • Related