简体   繁体   中英

Data Grid View Selection c#

Recently I made the 2048 game using a DataGridView. Everything works except for the blue selection/focus that appears on the DataGrid when my form starts and I use the arrow keys. I tried to remove it with ClearSelection(), works except for the arrows. How could I disable the blue selected cell? How can I disable the arrows?

public Form1_Load (......)
{    
DataGridView1.ClearSelection();
}

Image Link (I need more reputation to upload it on the site)

http://s23.postimg.org/beekn9i6z/Immagine.png

Screenshot of Datagrid during Runtime

http://s1.postimg.org/s5loh0uvj/datagrid.png

Handling selection in form load is too early because form is not shown yet. Perform datagridview clear selection in form shown event.

 private void Form1_Shown(object sender, EventArgs e)
    {
           DataGridView1.ClearSelection();
    }

OR

 void dataGridView2_SelectionChanged(object sender, EventArgs e)
    {
        dataGridView2.ClearSelection();
    }  

尝试这个

DataGridView1.CurrentCell.Selected = false;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM