如何使用keyboar上的箭头键在数据网格视图中选择行 [英] how to select rows in datagrid view using arrow keys on keyboar

查看:101
本文介绍了如何使用keyboar上的箭头键在数据网格视图中选择行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据网格视图,我用鼠标选择行或单元格,以便colums / row / cells中的数据显示在文本框中....



无论单元格我单击数据网格中行的整个数据都显示在文本框中...

这里我想要的不仅仅是鼠标,而是每当我按下键盘上的向下箭头键或向上箭头键,我必须选择上排或下排,数据应显示在文本框中....



可以请你在这个逻辑中帮助我....







我编写的代码用于选择和显示文本框是......

i have a datagrid view, in that im selecting a row or cell with mouse so that the data in the colums/row/cells are displaying in textboxes....

whatever the cell i click the entire data of row in datagrid is displaying in the textbox...
here what i want is , not only the mouse, but when every i press down arrow key or up arrow key in keyboar, i must select upper row or lower row and the data should display in the text boxes....

can u please help me in this logic....



the code i written to select and display in the textboxes is...

private void cut_grid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

            if (e.RowIndex >= 0)
            {
                cut_grid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                DataGridViewRow row = this.cut_grid.Rows[e.RowIndex];
                cut_code.Text = row.Cells["Customer_Code"].Value.ToString();
                cut_name1.Text = row.Cells["Customer_Name"].Value.ToString();
                cut_name2.Text = row.Cells["Customer_Name2"].Value.ToString();
                iadd1.Text = row.Cells["Invoice_Address"].Value.ToString();
                iadd2.Text = row.Cells["Invoice_Address2"].Value.ToString();
                iadd3.Text = row.Cells["Invoice_Address3"].Value.ToString();
                iadd4.Text = row.Cells["Invoice_Address4"].Value.ToString();
}

推荐答案

使用CellEnter事件。它将完成这项工作:)
Use "CellEnter" event. It will do the job :)


这篇关于如何使用keyboar上的箭头键在数据网格视图中选择行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆