locked
Navigating to the next row in a dataset using WPF RRS feed

  • Question

  • Hi.

    I perused the example from http://msdn2.microsoft.com/en-us/library/ms771774.aspx on how to use datasets
    in WPF. They use dataset methods. They Give an example of how to add a new row. The do not show how
    to get to the next row.

     

    An older ADO.Net book of mine showed this method which doesn't seem to work:
      private void btnNext_Click(object sender, System.EventArgs e)
      {
       System.Windows.Forms.CurrencyManager bc;

       bc = (CurrencyManager) this.BindingContext[this.dsEmployeeList1, "Employees"];
       bc.Position += 1;
       UpdateDisplay();
      }
    WPF doesn't appear to let me add the System.Windows.Forms to reach a currency manager.

     

    Basically, what I want to do is make an address book (intermediate hello world Smile where 2 buttons navigate back and forth between records while updating a textbox between them with the new ID. The new textbox dataset Id Would then
    update the rest of the record textboxes. I believe if I can accomplish row navigation than 'lots' of
    databinding reading would be the next step( Probably need that now).

    Sincerely,
    a re-virginized C# enthusiast using C# express.

    Thanks for your time I hope I'm not wasting it. Considering the depth of knowledge on this board
    please let me know if my noob questions would be better posted somewhere else. I'll take no offense.

    ps. I do see that LINQ something to learn. I tried SQLMetal.exe(I think that's the name) which
    I thought would make using SQL express queries easier. However when I tried I got the message: index out
    of range. (Obviously lots more reading to do)
    If someone could point me to a 'easy' site on using linq and sql server, it would be much appreciated.
    The only linq pages I found where those using local collections to use LINQ.


     

    Thursday, March 20, 2008 7:47 PM

Answers

  •  

    Hi sum1nil,

     

    the CurrencyManager was used in Windows Forms. In WPF this job is done by CollectionViews. For Ado.NET you have a

    ICollectionView foreach DataView (or each DataTables defaultView).

     

    You get the Default-CollectionView by calling the static GetDefaultView-Method of CollectionViewSource-class. Pass in your table. On the returned ICollectionView simply call the MoveCurrentToNext-Method. Following code does this. Customers is a table in the typed DataSet referenced in dataSet-Variable:

     

    Code Snippet

    ICollectionView cv = CollectionViewSource.GetDefaultView(dataSet.Customers);

    cv.MoveCurrentToNext();

     

     

    Thursday, March 20, 2008 7:56 PM

All replies

  •  

    Hi sum1nil,

     

    the CurrencyManager was used in Windows Forms. In WPF this job is done by CollectionViews. For Ado.NET you have a

    ICollectionView foreach DataView (or each DataTables defaultView).

     

    You get the Default-CollectionView by calling the static GetDefaultView-Method of CollectionViewSource-class. Pass in your table. On the returned ICollectionView simply call the MoveCurrentToNext-Method. Following code does this. Customers is a table in the typed DataSet referenced in dataSet-Variable:

     

    Code Snippet

    ICollectionView cv = CollectionViewSource.GetDefaultView(dataSet.Customers);

    cv.MoveCurrentToNext();

     

     

    Thursday, March 20, 2008 7:56 PM
  • Who needs to audit college classes with you guys around! Perfect answer. I think I love this forum.

     

    Thursday, March 20, 2008 9:12 PM