C++Learn C++

This Is How To Use The VCL StringGrid Component In A C++ App

C++ Builder has a lot of great components you can use to create a C++ app and StringGrid (TStringGrid) is one of these. A StringGrid  represents a grid control designed to simplify the handling of strings.

We can easily add a TStringGrid object to a form to represent textual data in a tabular format. StringGrid provides many properties to control the appearance of the grid, as well as events and methods that take advantage of the tabular organization of the grid in responding to user actions. StringGrid introduces the ability to associate an object with each string in the grid. These objects can encapsulate any information or behavior represented by the strings that are presented to the user.

What are the properties of TStringGrid?

ColCount and RowCount

ColCount specifies the number of columns in the grid. We can read Column Count to determine the number of entries in the Columns array or we can add or delete rows at the bottom of the grid.

RowCount specifies the number of rows in the grid, The value of RowCount includes the scrollable rows in the grid, but not the fixed row with the headers. We can read RowCount to determine the number of rows in the grid or we can set RowCount to add or delete rows at the bottom of the grid.

Here is a example below,

Cells Array

Cells array lists the strings for each cell in the grid. We can use Cells to access the string within a particular cell. ACol is the column coordinate of the cell, and ARow is the row coordinate of the cell. The first row is row zero, and the first column is column zero. The ColCount and RowCount property values define the size of the array of strings. Each grid member is String member which means they are UnicodeString, can be used with worldwide languages.

Col and Row

Col property is the column number of the selected cell, or -1 if there is no cell selected.
Row is the number of the selected row.

DefaultColWidth and DefaultRowHeight

A StringGrid Example on a VCL form


You can download a free trial of C++ Builder right now.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20Introduction to C++Learn C++

Learn Copy Constructors in C++ Classes

C++C++11C++14C++17Introduction to C++Learn C++Syntax

Learn How To Use Types Of Destructors In C++?

C++C++11C++14Learn C++Syntax

How To Convert u32string To A wstring In C++

C++C++11C++14C++17C++20Introduction to C++Learn C++

How To Learn The Move Constructors In Modern C++?