Navigating within a dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to navigate to a specific record within a dataset.datatable. Some of my controls are bound to this datatable, and it would be nice to do something like

me.bindingcontext(MyDataset.MyDatatable).position=MyDataset.MyDatatable.FindByMyKeyFiel

But since the Position property is an integer, this obviously doesn't work. Instead Ive been looping through the entire table (i.e.

Me.BindingContext(MyDataset.MyDataTable).Position =
While Not Me.BindingContext(MyDataset.MyDataTable).Current("MyKeyField") = keyvalu
Me.BindingContext(MyDataset.MyDataTable).Position = Me.BindingContext(MyDataset.MyDataTable).Position +
End Whil

). This just seems wrong to me. Is there a better way?
 
Hi PMCguire,

I find it a nice routine you have made. Do not forget that underdeck a
shorter method would almost always do the same as your routine.

You can make it look nicer by first making a currencymanager as this
cma as new directcast(bindingcontext(mydataset.mydatatabble)
,currencymanager)
cma.Position = 0
While Not cma.Current("MyKeyField") = keyvalue
cma.Position += 1
End While

However I see also no better alternative at the moment.

Cor
 
Back
Top