|
TListView에서 마우스로 아이템을 클릭했을 경우
Label1->Caption 에 정확히 선택된 아이템의 Caption이 나타납니다.
그렇지만, 리스트뷰에서 아이템을 선택하고
마우스를 위,아래로 움직이다 보면..
Label1->Caption 에 이 전에 선택한 아이템의 caption 이 출력됩니다.
꼭 한타임씩 늦네용..
# 첨부파일의 이미지를 보시면..
일단 마우스로 5555를 선택하고 아래화살표방향키를 누르면
포커스는 6666에 가 있지만, Label1->Caption 에는 5555가 출력됩니다.. ㅠㅠ
완전 기초적인것 같지만.. -_-;
해결방법이 있을까용?
아래는 소스 부분인데...
많은 오류가 있습니다.
(예를들면, 마우스를 listview의 아이템에 정확히 선택하지 않았다던지..
아이템을 선택하지 않고 키보드의 위,아래 버튼을 눌르다던지 하면 말이죠.. ㅡ,.ㅡ)
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
ListView1->AddItem("1111", this);
ListView1->AddItem("2222", this);
ListView1->AddItem("3333", this);
ListView1->AddItem("4444", this);
ListView1->AddItem("5555", this);
ListView1->AddItem("6666", this);
ListView1->AddItem("7777", this);
ListView1->AddItem("8888", this);
ListView1->AddItem("9999", this);
ListView1->AddItem("0000", this);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListView1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if( Key == VK_UP || Key == VK_DOWN ) {
Label1->Caption = ListView1->Selected->Caption;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListView1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if( Button == mbLeft ) {
Label1->Caption = ListView1->Selected->Caption;
}
}
//---------------------------------------------------------------------------
|