• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

diffrent or sum tow colum in datagridview

i have 4 colums
 1 - name   2- start date   3-end date  4- cost A  5-cost B

1-i want faind diffrent  date betwen c2 and c3 and in new colim name it tot_day
2- i want faind sum  c4 + c5
and c4-c5

i use visaul basic 2005
access
windose aplaction
0
ziayd2009
Asked:
ziayd2009
  • 3
  • 2
1 Solution
 
grayeCommented:
If you are using a DataTable to store your 5 existing columns, then you can just add a few extra columns to the DataTable.  These new columns will contain an "expression".   So, in your case, you'd add a new column for tot_day and set it's Expressio property to "[start date]-[end date]"

Take look at this article... it has some downloadable examples too.

http://www.emmet-gray.com/Articles/ADO_Expressions.htm
0
 
ziayd2009Author Commented:

i  use tihes cood  from example in article
 Dim dc As DataColumn
     
  LoadData()
        dc = New DataColumn("tt1")
        dc.DataType = GetType(Integer)
        dc.Expression = "tt1 + tt3"  ' two column types
        dataset3.Tables("tbl").Columns.Add(dc)
        Me.DataGridView1.DataSource = dataset3.Tables("tbl")

Open in new window

after tht it give me msg :-
Cannot set Expression property due to circular reference in the expression
why is not work
note:-
colum tt1 and tt2 is type of integr
0
 
grayeCommented:
Yeah, you can't call the new column by the name tt1 (in your example).   Call it something else... anything else.
0
 
ziayd2009Author Commented:
why ,
can  u explain more
what i can call colum ?
 can i call like tot1 or total
thank u
0
 
grayeCommented:
Yeah, that'd do just fine...   the problem is that you can't create a new column using a name that already exists.  So, "total" would do just fine.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now