views:

527

answers:

2

I have a Windows form app. I get data based on a row position in a DataTable. I have a TotalCount variable and a CurrentPos variable. The button next should get the next row and the button previous should get the previous. These buttons should be enabled/disabled when there is data available.

My brain is much can you provide the logic

+3  A: 

Is it not a simple

m_NextButton.Enabled =  CurrentPos < (TotalCount - 1) ;
m_PreviousButton.Enabled = CurrentPos > 0;

You need to call this when you

  1. Add to your DataTable
  2. Change Your Selection
  3. Remove from your datatable
NotJarvis
At what point do you increment the CurrentPos, before the call to get records or after. When the form starts the CurrentPost = 0 but you can't increment before the call to get records as it will miss the first record
Jon
Not to worry, I have done it. Thanks for your help, having a bad brain day!
Jon
A: 

You might also want to look at the BindingNavigator class which will do this for you

Lee