datagridview使用了FullRowSelect属性,就是想让用户随便哪点哪一行时,哪行高亮选中,但发现有问题了;
    就是用户想copy某cell的一个字段时,粘贴过去,整行的内容都copy去了,不得不用鼠标点两下哪个单元copy
 第二个就是想用户按tab键跳到另一个cell单元时,能改变其底色,跳出恢复底色

解决方案 »

  1.   

    底色的问题,如果所有的cell都是统一的,那可以用grid的属性进行设计。
    如果单独设计,那就用,beforeActive和afterActive
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication142
    {
        public partial class Form1 : Form
        {
            WebBrowser WB = new WebBrowser();        public Form1()
            {
                InitializeComponent();            DataGridView DGV = new DataGridView();
                DGV.Parent = this;
                DGV.Dock = DockStyle.Fill;
                DGV.SelectionMode = DataGridViewSelectionMode.FullRowSelect;            DGV.Columns.Add(new DataGridViewTextBoxColumn());
                DGV.Columns.Add(new DataGridViewTextBoxColumn());
                DGV.Columns.Add(new DataGridViewTextBoxColumn());
                DGV.Rows.Add(5);            DGV.CellFormatting += new DataGridViewCellFormattingEventHandler(DGV_CellFormatting);
                DGV.KeyDown += new KeyEventHandler(DGV_KeyDown); 
            }        void DGV_KeyDown(object sender, KeyEventArgs e)
            {
                DataGridView DGV = (DataGridView)sender;            if (e.Control && e.KeyCode == Keys.C)
                {
                    Clipboard.Clear(); 
                    Clipboard.SetText(DGV.CurrentCell.Value.ToString()); // 只拷贝当前单元格值
                    e.SuppressKeyPress = true;
                }
            }        void DGV_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
            {
                DataGridView DGV = (DataGridView)sender;            if (DGV.CurrentCell.RowIndex == e.RowIndex && 
                    DGV.CurrentCell.ColumnIndex == e.ColumnIndex)
                    e.CellStyle.SelectionBackColor = Color.Green; // 修改当前单元格选择背景
            }
        }
    }
      

  3.   

    void DGV_KeyDown(object sender, KeyEventArgs e)
            {
                DataGridView DGV = (DataGridView)sender;            if (e.Control && e.KeyCode == Keys.C)
                {
                    Clipboard.Clear(); 
                    Clipboard.SetText(DGV.CurrentCell.Value.ToString()); // 只拷贝当前单元格值
                    e.SuppressKeyPress = true;
                }
            }这个不行,还是一样的复制了整行