|
덕분에 해결했습니다..
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;
for(int row = AfterIndex + 1; row < row_count; row++)
StringGrid->Rows[row] = StringGrid->Rows[row+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);
}
smleelms 님이 쓰신 글 :
: 음.. Insert 함수에서는 Row를 늘이시고 Row의 내용들을 한줄씩 밑으로 내리신 후에 해당 Row를 clear시키셨는데, delete 함수에서는 그냥 RowCount를 하나 줄이셨네요. 따라서 제일 아래의 Row내용이 삭제가 되겠지요..
:
: 따라서 Insert함수처럼 해당 Row를 Clear 시키신 후에 아래 Row의 내용들을 한줄씩 올리신 후에, RowCount를 하나 줄이시는게 맞겠지요.
:
: 그럼, 좋은 결과 있으시기를...
:
: 사랑니 님이 쓰신 글 :
: : 안녕하세요 ^^ 많은 도움 부탁드립니다
: : 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);
: : }
|