Skip to content

Navigate in record form

jmal salih

Asked May 6, 2014, 1:02 AM EDT1 answer
Share
LinkedInX
I wante c# code for (next-previous-first-last)windows form buttons
thank alot

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • nacro cheick
    0
    hi

    this is an exemple code

    datarow dRow;
    int pos;
    int maxrecord = ds.Tables[0].Rows.Count;

    Code
    private void NavigateRecords()
       {
     dRow = ds.Tables[0].Rows[pos];
    txtFirstName.Text = dRow.ItemArray.GetValue(1).ToString();
       txtSurname.Text = dRow.ItemArray.GetValue(2).ToString();
       txtJobTitle.Text = dRow.ItemArray.GetValue(3).ToString();
       txtDepartment.Text = dRow.ItemArray.GetValue(4).ToString();
    }
    
    
    for your next button, increment pos.

    exemple


    private void Next()

    {

         if(pos < maxrecord)

           {

               pos++;

               NavigateRecords()

            }

    }

    it's the same for previous.

    Code
    private void goLast()
    {
    
    
           pos=maxrecord;
            NavigateRecords()
    }


          
    0