我可以为ComboBox的值设置数据类型吗?
我想在RegisterHotKey()函数中使用一长串keyCodes,它接受一个uint VK数据类型。
RegisterHotKey(_hWnd, 1, (uint)fsModifiers.Control, (uint)Keys.Insert);
我将我的组合框值设置为"(uint)Keys.Insert"。然后我将值赋给一个字符串变量,并尝试在RegisterHotKey函数中使用变量cast作为(uint),但我不断收到数据类型错误。
要么我没有正确行事,要么就这样做了?
...谢谢
cboHotkeyModifier.ValueMember = "Value";
cboHotkeyModifier.DisplayMember = "Text";
items = new[] {
new { Value = "", Text = "" },
new { Value = "Shift", Text = "Shift" },
new { Value = "(uint)fsModifiers.Control", Text = "Control" },
new { Value = "Alt", Text = "Alt" }
};
cboHotkey.ValueMember = "Value";
cboHotkey.DisplayMember = "Text";
items = new[] {
new { Value = "D0", Text = "0" },
new { Value = "D1", Text = "1" },
new { Value = "D2", Text = "2" },
new { Value = "D3", Text = "3" },
new { Value = "D4", Text = "4" },
};
cboHotkey.DataSource = items;
keyData = cboHotkey.SelectedItem;
keyModifier = cboHotkeyModifier.SelectedItem;
RegisterHotKey(_hWnd, 1, keyModifer, keyCode);