Solved

diffrent or sum tow colum in datagridview

Posted on 2011-02-26
5
285 Views
Last Modified: 2012-06-21
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
Comment
Question by:ziayd2009
  • 3
  • 2
5 Comments
 
LVL 41

Expert Comment

by:graye
Comment Utility
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
 

Author Comment

by:ziayd2009
Comment Utility

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
 
LVL 41

Expert Comment

by:graye
Comment Utility
Yeah, you can't call the new column by the name tt1 (in your example).   Call it something else... anything else.
0
 

Author Comment

by:ziayd2009
Comment Utility
why ,
can  u explain more
what i can call colum ?
 can i call like tot1 or total
thank u
0
 
LVL 41

Accepted Solution

by:
graye earned 50 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now