c++builder中使用 if(MessageBox(NULL, "确认删除吗?", "提示", MB_YESNO | MB_ICONQUESTION) == ID_YES)
发现第二次执行到选择框跳到model窗体后面了,后来改为
if(Application->MessageBox( "确认删除选择的一行吗?", "提示", MB_YESNO | MB_ICONQUESTION) == ID_YES)
-----------------------------
ListView如果需要表格样式,记得把ViewStyle属性值 改为vsReport,方便观看RowSelect=true,不编辑ReadOnly=true
增行数据:
for(int i=0; i<ListView1->Items->Count;i++)
{
if(ListView1->Items->Item[i]->Caption ==Trim(EditPrefix->Text)
&& ListView1->Items->Item[i]->SubItems->Strings[0] ==Trim(EditNode->Text))
{
ShowMessage("这个节点和节点前缀组合已经存在,不能重复添加!");
return ;
}
}
this->ListView1->Items->BeginUpdate();
TListItem *newItem=this->ListView1->Items->Add();
newItem->Caption = Trim(EditPrefix->Text);
newItem->SubItems->Add(Trim(EditNode->Text));
newItem->SubItems->Add(ComboBox1->ItemIndex);
this->ListView1->Items->EndUpdate();
删除行:
if(ListView1->Selected){
this->ListView1->Items->BeginUpdate();
this->ListView1->Selected->Delete();
this->ListView1->Items->EndUpdate();
}else{
ShowMessage("请点击一下要删除的行使其被选中,然后才能删除!");
}
