DISCOVER
×

How to Select a Cell in a DataGridView

Updated July 20, 2017

Knowing how to select a cell in Data Grid View control using Microsoft Visual Basic.NET can make your Windows applications more user-friendly. You use a Grid control to show data in a tabular format similar to a table. You can use it to show small or large amounts of data. VB.NET is an object-oriented computer programming language you can use to create Windows applications. In a few steps, you can create a VB.NET project, and use a Grid control to display data and select an individual cell.

Start Microsoft Visual Basic Express. Click "New Project..." on the left-hand pane of your screen and select "Windows Forms Application." Click "OK."

Double-click "Button" on the "Toolbox" pane to add a new button control. Double-click "DataGridView" to add a new grid control. Double-click "Button1" to open the "Form1.vb" module.

Type the following text to define the number of columns and define the column names of the Data Grid View control:

DataGridView1.ColumnCount = 3

Type the following text to load data to the Data Grid View control:

Type the following text to select the last cell in the second row:

Press "F5" to run your program and click "Button1" to load data and select the last cell in the second row.

Things You'll Need

  • Microsoft Visual Basic Express
Cite this Article A tool to create a citation to reference this article Cite this Article

About the Author

Jaime Avelar is a professional writer whose programming articles appear on various websites. He has been a software programmer since 2000. Avelar holds a Master of Science in information systems from the University of Texas at Arlington.