線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2747
推到 Plurk!
推到 Facebook!

StringGrid的刪除函數

 
haman
中階會員


發表:46
回覆:137
積分:56
註冊:2005-03-10

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-09-23 18:29:16 IP:211.76.xxx.xxx 未訂閱
參考RedSnow大大在 http://delphi.ktop.com.tw/topic.php?topic_id=70750 提出的插入函數改出來的刪除    這個函數可能不入版上的各位大大的眼裡, 但對於新手來說,應該是會很有幫助的吧?(至少我就找了很久>"<) 另一方面也是怕自已以後會找不到把改出來的東西 放在這至少不會跑吧 < class="code"> //RedSnow大大版Insert(改delete) void __fastcall DeleteRow(TStringGrid *StringGrid, long DelIndex) { SNDMSG(StringGrid->Handle, WM_SETREDRAW, false, 0); try { int row_count = StringGrid->RowCount; for (int row = DelIndex; row < row_count; row ) StringGrid->Rows[row] = StringGrid->Rows[row 1]; StringGrid->RowCount = row_count - 1; } catch (...) { SNDMSG(StringGrid->Handle, WM_SETREDRAW, true, 0); } SNDMSG(StringGrid->Handle, WM_SETREDRAW, true, 0); RECT R = StringGrid->CellRect(0, DelIndex); InflateRect(&R, StringGrid->Width, StringGrid->Height); InvalidateRect(StringGrid->Handle, &R, false); } 這是RedSnow大大版的Insert
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);
}
記得要在header中加入 void __fastcall DeleteRow(TStringGrid *StringGrid, long AfterIndex); 或 void __fastcall InsertRow(TStringGrid *StringGrid, long AfterIndex); ==================================== 懂的不多,卻想學的更多,搞得不自覺的將問題複雜化@@
系統時間:2024-07-01 16:20:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!