怎么把光标设置在edit中的指定位置
是这样的,设置IP地址,用4个edit,按键盘方向键时如果光标已经在当前edit的最后面要跳到下一个edit的最前面.
[解决办法]
void __fastcall TForm1::Edit1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key == VK_RIGHT)
{
if (Edit1->SelStart == Edit1->Text.Length())
{
Edit2->SetFocus();
Edit2->SelStart = 0;
}
}
}
//---------------------------------------
void __fastcall TForm1::Edit2KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key == VK_LEFT)
{
if (Edit2->SelStart == 0)
{
Edit1->SetFocus();
Edit1->SelStart = Edit1->Text.Length();
}
}
}