获取TListView选中行的内容

通过鼠标点击获取TListView选中的内容,用的是OnClicked事件,不是OnChange事件,代码如下:
 

   TPoint p;
   GetCursorPos(&p);
   p = lvLoginUser->ScreenToClient(p);
   TListItem  *   pItem = lvLoginUser->GetItemAt(p.x, p.y);

   if(pItem == NULL)return;

   m_nID     = atoi(pItem->Caption.c_str());//选中的ID
   
   edtUserID->Text    = pItem->SubItems->Strings[0];
   edtUserName->Text  = pItem->SubItems->Strings[1];
   if(m_bSeePassword)
      edtPwd->Text    = GetPwdString(m_nID);
   else
      edtPwd->Text    = "******";

   cbbLimit->ItemIndex= g_pRoleManage->GetRoleTypeOfRoleName(pItem->SubItems->Strings[3]);
   edtPhone->Text     = pItem->SubItems->Strings[4];
   mmoMarks->Text     = pItem->SubItems->Strings[5];

 

你可能感兴趣的:(C++Builder6,C++)