How to code the 'Next' botton?

BenTam-3003 686 Reputation points
2022-03-02T05:22:37.083+00:00

Dear All,

The course box is a "ListViewCustom" control. How to assign code to the next button?

179068-form.gif

Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Sreeju Nair 12,756 Reputation points
    2022-03-02T05:27:52.137+00:00

    you will get the ListView's selectedIndex, add 1 to it and set that item as selected. Refer the following code.

    private void btnNext_Click(object sender, EventArgs e)
    {
        // Get the currently selected items index
        int index = listView1.SelectedIndices[0] + 1;
    
        // If you are in the last record, don't do anything.
        if (index >= listView1.Items.Count)
            return;
    
        // Set the Selected property to true for the item at the index. 
        listView1.Items[index].Selected = true;
    }
    

    Hope this helps


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.