iFocus.Life News News - Breaking News & Top Stories - Latest World, US & Local News,Get the latest news, exclusives, sport, celebrities, showbiz, politics, business and lifestyle from The iFocus.Life,

How to Keep the Check Box Value on a Gridview Sort

104 45
    • 1). Open Visual Studio 2010 by clicking on its program icon. When it loads, select "File/New/Project "and click "Visual C#/Windows Forms Application." A new Windows Form Application project is created, and a blank Windows Form appears in the main editor window.

    • 2). Locate the "Toolbox" panel on the right or left-hand side of the screen. The "Toolbox" displays a list of items that can be added to a Windows Form. Locate the items named "CheckBox" and "DataGridView."

    • 3). Click and drag both "DataGridView" and "CheckBox" onto the Windows Form and release the mouse button to place the items. Place the "DataGridView" first, and place the "CheckBox" near to the "DataGridView."

    • 4). Double-click the "CheckBox" to open the source code view for the "buttonChecked" event. This code will run whenever the check box is clicked on.

    • 5). Write the following statements to add values to the "DataGridView." These items will keep the same value no matter how many times the "CheckBox" is clicked. Write the following in between the curly brackets that immediately follow the function labeled "checkBox1_CheckedChanged":

      dataGridView1.Rows.Insert(0, 1, 2);

    • 6). Execute the program by pressing the green "Play" button. The program displays a Windows Form with a grid and a check box. By clicking on the check box, you can add rows to the check box with values.

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time
You might also like on "Technology"

Leave A Reply

Your email address will not be published.