請問stringgrid的問題 |
尚未結案
|
opium
一般會員 發表:22 回覆:11 積分:6 註冊:2003-02-23 發送簡訊給我 |
|
RedSnow
版主 發表:79 回覆:1322 積分:845 註冊:2003-12-15 發送簡訊給我 |
opium 您好: 以下資料摘自vcl.components.using Mini FAQ:
(Q4.4) How do I insert/remove a row or column in a TStringGrid? (A4.4) Implement this functionality manually by manipulating the RowCount or ColCount property, then shifting the contents of the surrounding cells. The following function can be used to insert a row. Inserting a column, or deleting a row or column can be accomplished via a similar technique. void __fastcall InsertRow(TStringGrid *StringGrid, long AfterIndex) { SNDMSG(StringGrid->Handle, WM_SETREDRAW, false, 0); try { int row_count = StringGrid->RowCount; StringGrid->RowCount = row_count 1; for (int row = row_count; row > AfterIndex 1; row--) StringGrid->Rows[row] = StringGrid->Rows[row - 1]; StringGrid->Rows[AfterIndex 1]->Clear(); } catch (...) { SNDMSG(StringGrid->Handle, WM_SETREDRAW, true, 0); } SNDMSG(StringGrid->Handle, WM_SETREDRAW, true, 0); RECT R = StringGrid->CellRect(0, AfterIndex); InflateRect(&R, StringGrid->Width, StringGrid->Height); InvalidateRect(StringGrid->Handle, &R, false); }以上的函式可新增一個空的橫行 (Row) 到 StringGrid 指定行的下方,使用方式如下: InsertRow(StringGrid1, 2); 上例是在 StringGrid1 的第 2 行之下插入一個空行,刪除的部份請參照範例比照辦理,您參考一下。 發表人 - RedSnow 於 2005/05/11 21:01:20 |
opium
一般會員 發表:22 回覆:11 積分:6 註冊:2003-02-23 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |