Quickly empty Stringgrid cell contents

Source: Internet
Author: User

When we use Stringgrid, we often need to clear the contents of all the cells, and I use the following methods:

grdFileList->RowCount=1;  //设置总行数,有一行标题行
for (irow=0; irow < OpenDialog1->Files->Count; irow++) //这个例子是将对话框中选择的文件放到GRID中
{
grdFileList->RowCount++; //总行数增加
grdFileList->Rows[irow+1]->Clear();  //清空当前行所有单元格内容
grdFileList->Cells[0][irow+1] = "";  //第0列一般为选择列标记
grdFileList->Cells[1][irow+1] = ExtractFileName(OpenDialog1->Files->Strings[irow]); //文件名
grdFileList->Cells[2][irow+1] = OpenDialog1->Files->Strings[irow]; //含路径文件名
....
....
}
if (grdFileList->RowCount>1)
grdFileList->FixedRows = 1; //第一行为固定标题行,将其变为灰色

Conclusion: This design program will ensure that each new line added is up-to-date or blank.

Note: If you use grdfilelist->rowcount=1; only, the number of rows becomes long, and the old content is displayed.

Other: The above is debugged in C + + builder6/c++ Builder 2009.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.