By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

Creating a complex expression for a Typed Dataset element

P: n/a
How can I create a property or function for a typed datasets column?
By this I need to add a new column (element) to the table or override an
existing column.
For instance I have an Invoice table that needs to have a Status property.
This status property has to read the other elements in the table to
determine what the status is and return a string.
I know that I can enter this in the expression fields, but as the
expressions become more complex this becomes unmanageable.
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Andrew,
When my "expression" becomes too complex for a DataColumn.Expression I use
the DataTable.ColumnChanged event to use VB.NET code to calculate the
expression.

Something like (unchecked):

Private Sub Table_ColumnChange(...)
If e.Column.ColumnName <> "Column1" _
AndAlso e.Column.ColumnName <> "Column2" _
AndAlso e.Column.ColumnName <> "Column3" Then

If e.Row.IsNull("Column1") Then Exit Sub
If e.Row.IsNull("Column2") Then Exit Sub
If e.Row.IsNull("Column3") Then Exit Sub

Dim value1 As DateTime = CDate(e.Row.IsNull("Column1"))
Dim value2 As DateTime = CDate(e.Row.IsNull("Column2"))
Dim value3 As TimeSpan = DirectCast(e.Row.IsNull("Column3"),
TimeSpan)

Dim value4 As TimeSpan

value4 = value2.Subtract(value1).Add(value3)

e.Row("Column4") = value4

End If
End Sub

Hope this helps
Jay

"Andrew" <an*****@nospam.dbasplus.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
How can I create a property or function for a typed datasets column?
By this I need to add a new column (element) to the table or override an
existing column.
For instance I have an Invoice table that needs to have a Status property.
This status property has to read the other elements in the table to
determine what the status is and return a string.
I know that I can enter this in the expression fields, but as the
expressions become more complex this becomes unmanageable.

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.