求助: 获取textBox中指定位置一个字符。。。
求助: 获取textBox中指定位置一个字符。。。没有办法了,textBox无法限制光标始终在字符串最后。
只能通过判断,光标位置和光标处字符来判断是否可以输入了。。。。
获取textBox中指定位置一个字符, 不知道textBox控件有没有现成的函数可以使用。
如果没有现成的函数,自己如何写才能最简洁。。。
2022-12-12 23:55
2022-12-13 08:09
程序代码:
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
textBox1.Text = textBox1.Text + e.KeyChar;
e.KeyChar = (char)0;
}
2022-12-13 08:53
2022-12-13 12:54
程序代码:private: wchar_t rechar(String^Str, int _pos)
{
const wchar_t* pchar = (const wchar_t*)(System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(Str)).ToPointer();
wchar_t retuchar = pchar[_pos];
return retuchar;
}
2022-12-13 13:28
程序代码:private: System::Void textBox1_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e)
{
textBox1->Select(textBox1->Text->Length, 0);
......................
......................
}[此贴子已经被作者于2022-12-13 13:39编辑过]
2022-12-13 13:36
事出反常,必有另类。
2022-12-13 18:38
2022-12-14 13:14
2022-12-14 15:17
2022-12-14 16:35