[英]How do i select multiple cells of datagridview without pressing Ctrl key?
I have a datagridview control which i am using to make a weekly schedule. 我有一个datagridview控件,我正在使用它来制定每周计划。
User can select different time of different days by selecting multiple cells from the gridview. 用户可以通过从gridview中选择多个单元格来选择不同日期的不同时间。
Problem here is that once the user selects multiple cells for the first time and would like to select more cells , he need to press the Ctrl key from the keyboard which is very difficult for end user to use as in the case if he/she has no keyboard available or he is not aware of pressing Ctrl key. 这里的问题是,一旦用户第一次选择了多个单元格并想要选择更多的单元格,他就需要从键盘上按Ctrl键,这对于最终用户来说非常困难,就像他/她拥有没有可用的键盘,或者他不知道按Ctrl键。
I have attached a snapshot. 我已附上快照。 Please provide me any solution if you have.
如果有,请提供任何解决方案。
也许您可以通过DataGridView的CellMouseDown
, CellMouseMove
和CellMouseUp
事件来实现。
You can use input simulator for holding Control key and as Wudge mentioned with mouse events you can solve your issue. 您可以使用输入模拟器来按住Control键,并且正如Wudge在鼠标事件中提到的那样,可以解决您的问题。
http://inputsimulator.codeplex.com/releases/view/37570 http://inputsimulator.codeplex.com/releases/view/37570
private void Form1_Load(object sender, EventArgs e)
{
List<Person> mypeople = new List<Person>();
mypeople.Add(new Person() { Key = 3, Value = "Turgay" });
mypeople.Add(new Person() { Key = 4, Value = "Hamsi" });
mypeople.Add(new Person() { Key = 5, Value = "Cabbar" });
dataGridView1.DataSource = mypeople;
dataGridView1.MouseEnter += DataGridView1_MouseEnter;
dataGridView1.MouseLeave += DataGridView1_MouseLeave;
}
private void DataGridView1_MouseEnter(object sender, EventArgs e)
{
InputSimulator.SimulateKeyDown(VirtualKeyCode.CONTROL);
}
private void DataGridView1_MouseLeave(object sender, EventArgs e)
{
InputSimulator.SimulateKeyUp(VirtualKeyCode.CONTROL);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.