|
안녕하세요 ^^ 많은 도움 부탁드립니다
AfterIndex 를 인자로 Row를 추가 삭제하는 함수입니다.
Row추가 함수는 특정 Row에 추가되는것이 확인되었는데 Row삭제 함수는
무조건 제일 밑에있는 Row가 삭제되네요...
원인이 무엇일까요?
고수님들에 조언 부탁드릴께요 ^^
그럼 즐거운하루 되세요~~
// Row추가함수
void __fastcall TForm1::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);
throw;
}
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 삭제함수 <--요놈이 안되는놈입니다
void __fastcall TForm1::DeleteRow(TStringGrid *StringGrid, long AfterIndex)
{
SNDMSG(StringGrid->Handle,WM_SETREDRAW,false,0);
try
{
int row_count = StringGrid->RowCount ;
StringGrid->RowCount = row_count - 1;
}
catch(...)
{
SNDMSG(StringGrid->Handle,WM_SETREDRAW,true,0);
throw;
}
SNDMSG(StringGrid->Handle,WM_SETREDRAW,true,0);
RECT R = StringGrid->CellRect(-1,AfterIndex);
InflateRect(&R,StringGrid->Width*-1,StringGrid->Height*-1 );
InvalidateRect(StringGrid->Handle ,&R,false);
}
|