TValueListEdit控件在程序中控制单元格是否可编辑
想实现的效果:
1、点击按钮时ValuelistEdit可编辑(key与Value都可以编辑),再点击一次不可编辑(key与Value都不可以编辑)
2、第二行的Value值可编辑,key值不可编辑。
我的代码如下,为什么会没有效果。在StringGrid控件下,同样的写法却有效果。
void __fastcall TForm1::VLEditSelectCell(TObject *Sender,
int ACol, int ARow, bool &CanSelect)
{
/* if(VLEdit->Col != 0 && VLEdit->Row == 1)
{
VLEdit->KeyOptions<<keyEdit;
VLEdit->Options<<goEditing;
}
else
{
VLEdit->KeyOptions>>keyEdit;
VLEdit->Options>>goEditing;
}
*/
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Form1->flag = -1;//flag初始值为-1
VLEdit->InsertRow("1", "潮汐海灵",1);
VLEdit->InsertRow("2", "德邦总管", 1);
VLEdit->InsertRow("3", "安妮", 1);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
flag*=-1;
if(1 == flag)
VLEdit->Options>>goEditing;
if(-1 == flag)
VLEdit->Options<<goEditing;
}
//---------------------------------------------------------------------------
private:// User declarations
bool m_bFlag;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
m_bFlag = true;
VLEdit->InsertRow("1", "潮汐海灵",1);
VLEdit->InsertRow("2", "德邦总管", 1);
VLEdit->InsertRow("3", "安妮", 1);
}
// ---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
m_bFlag = !m_bFlag;
VLEdit->Options = m_bFlag? VLEdit->Options << goEditing:
VLEdit->Options >> goEditing;
}