Current Record?

JaedenRuiner

Well-known member
Joined
Aug 13, 2007
Messages
340
Programming Experience
10+
Okay,

BindingSource, BindingNavigator, DataSet (Typed), TableAdapter (Typed). All on the form. Dropped in a "Details" view of the appropriate Table I wish to view. Now for the kicker:

Where's the current Row?

If I remember they used to be called "cursors" or something of the like in old DAO and ADODB back in my Access days, but this is SQL Server and ADO.Net, so I haven't a clue if that's still the same.

See on the Binding Navigator there is that "PositionItem" property which is set to a ToolStripTextBox. Where is that populated...with what property, value, etc. I've examined the DataSet/DataTable/DataView types and I don't see any "CurrentRecord" property, so i'm a little confused on the BindingNavigator control and how it works with the details form.

Thanks
 
When dealing with binding Sources and their position, instead of using the DataTable.Row(position) method always reference the "Current" property of the bindingsource:
VB.NET:
'Given DataSet is A Typed Dataset with a DataTable and DataRows
'MyTypedDataSet, MyTypedDataTable, MyTypedDataTableRow

public Property CurrentListRow() as MyTypedDataTableRow
 Get
  if (BindSource.Current isnot Nothing) andalso (TypeOf BindSource.Current is DataRowView) then
     dim dr as DataRow = DirectCast(BindSource.Current, DataRowView).Row
     if (TypeOf dr is MyTypedDataTableRow)
       return DirectCast(dr, MyTypedDataTableRow)
    end if
  end if
  return nothing
 end get
end property
end sub

now, if you are only using the binding source on your typed dataset, you don't necessarily need all the typeof checks, but that's the basic setup. BindingSource.Current is a DataRowView type when the BindingSource.DataSource is a DataTable or Dataset (with DataMember pointing to Table Name).
The DataRowView.Row property always points to the precise DataRow in the DataTable source where the BindingSource's Position is indicating, regardless of the DataTable Row's Ordinal Index.

If I want to get a DataRow ,what i have to do.. without going to their binding position..bcoz without going its position i can't get the current


i need this bcoz .. some time we set various command on position change... if someone give me a function to get DataRow by bindingSource with out going to a position ,... it would be very helpful
 
Back
Top