EpiDataView Object
EpiDataView Object
The EpiDataView Object encapsulates a DataView of a particular DataTable that corresponds to a Table in your database. There is usually a direct correlation between a Database Table and an EpiDataView. To investigate the specific EpiDataViews available for a given UI application, see the Object Explorer tool's Data Objects tab.

How to Access the EpiDataView Object
The EpiDataView object is available under the UI Object tab and the Data Objects Tab. The UI tab contains the methods and properties based on the EpiDataView, in this case, the Job Entry form. the Data Objects Tab displays the actual field data for the selected object.
Assuming you are still inside the Object Explorer follow these steps to review the details of the Job Entry EpiDataView:
1. Select the UI Object Tab to see the available properties and methods for the Job Entry EpiDataView.
2. Select the Data Objects tab to view the actual fields to see what properties and methods are available
3. To view the DataView (fields) behind the object (tables) select the Data object and then click the DataView symbol.
Sample Code Uses for the EpiDataView Object
Instructor Note
Have the class open the EpiDataView object and review some of the examples in that listing.
Below are a few examples to provide or discuss for uses.
? A reference to an EpiDataView object is usually obtained through the Transaction objects EpiDataViews collection as shown in the following line of code:
Dim edv As EpiDataView = CType(oTrans.EpiDataViews("ViewName"), EpiDataView)
Alternatively, the same entry using C# is
EpiDataView edv = (EpiDataView)oTrans.EpiDataViews("JobHead");
? To access or set a field's value in an EpiDataView, use the following VB.NET code: (写入数据到EpiDataView)
Dim someValue As String = edv.dataView(edv.Row)("FieldName")
edv.dataView(edv.Row)("FieldName") = someValue
Alternatively, the same entry using C# is
string someValue = (string)edv.dataView[edv.Row]["FieldName"];
edv.dataView[edv.Row]["FieldName"]= someValue;
? The Notify() Method notifies bound controls of updates to the underlying EpiDataView. The method uses this code for VB.Net:
(刷新绑定控件,即UI界面)
edv.Notify(New EpiNotifyArgs([FormName], edv.Row, edv.Column))
Alternatively, the same entry using C# is
edv.Notify(New EpiNotifyArgs([FormName], edv.Row, edv.Column));
? Another important method for this object is the InitializeCustomCodeI(). This method is
used to extend the properties of the object. The following code extends the propertis of the
PONUM inside the OrderHed EpiDataView. The VB.NET Code is:
Private Sub SetExtendedProps()
‘// Get EpiDataView reference
Dim edv As EpiDataView = CType(oTrans.EpiDataViews("OrderHed"), EpiDataView)
If edv.dataView.Table.Columns.Contains("PONum") Then
edv.dataView.Table.Columns("PONum").ExtendedProperties("ReadOnly") = True
edv.dataView.Table.Columns("PONum").ExtendedProperties("Enabled") = False
‘// or to make invisible…
‘edv.dataView.Table.Columns("PONum").ExtendedProperties("IsHidden") = False
End if
End Sub
The C# code is as follows:
private static void SetExtendedProps()
{
// Get EpiDataView reference
Dim edv As EpiDataView = CType(oTrans.EpiDataViews("OrderHed"), EpiDataView)
if (edv.dataView.Table.Columns.Contains("PONUM"))
{
edv.dataView.Table.Columns["PONum"].ExtendedProperties["ReadOnly"] = true
edv.dataView.Table.Columns["PONum"].ExtendedProperties["Enabled"] = false
// or to make invisible...
//edv.dataView.Table.Columns["PONum"].ExtendedProperties["IsHidden"] = false
}
}
Note The reference to make invisible in the above code demonstrates the manual way to hide a field. There is also an Extended Properties wizard available to manipulate these properties (discussed later in the course).
转自:http://spectragem.blog.163.com/blog/static/99994562201052934217726/