简体   繁体   English

如何在不按Ctrl键的情况下选择datagridview的多个单元格?

[英]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的CellMouseDownCellMouseMoveCellMouseUp事件来实现。

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.

相关问题 c# - 如何在不按CTRL键的情况下多选DataGridView行? - How to multiselect DataGridView rows without pressing CTRL key in c#? 如何在不按住Ctrl键的情况下在WPF DataGrid中选择多行? - How select multiple rows in WPF DataGrid without holding Ctrl Key? 在不按Control键的情况下选择多行 - Select multiple Rows without pressing Control Key 如何在datagridview C#中使用shift和Ctrl键选择多行 - how select multiple row using shift and Ctrl key in datagridview C# 在WPF中配置ListBox,这样我就可以在不保持CTRL键的情况下选择多个项目 - Configure ListBox in WPF so that I will be possible to select multiple items without holding CTRL key 如何在不使用C#按住CTRL键的情况下在UI网格中选择多行? - How to select multiple rows in a UI grid without holding CTRL key using C#? 按 T​​AB 键时绕过 DataGridView 中的只读单元格 - Bypass read only cells in DataGridView when pressing TAB key 如何通过按CTRL键在单个按钮上单次上传多个图像 - How to upload multiple images one singel time on single button by pressing CTRL key 如何使用Ctrl键+鼠标单击来选择多个控件? - How to use ctrl key + mouse click to select multiple controls? 我如何 select 多个表到 datagridview? - How can i select multiple table to datagridview?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM