| |

VerySource

 Forgot password?
 Register
Search
Author: kyoetsuu

How to achieve datagridview row color

[Copy link]

0

Threads

17

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-5-7 23:30:01
| Show all posts
dgv.DefaultCellStyle.BackColor
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-8 21:45:02
| Show all posts
Upstairs, no response!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-3 15:30:01
| Show all posts
Thank you22151146for your help, your code is very useful
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-3 19:15:01
| Show all posts
This can be done in DataGridView:

private int _selecting_index = 0;
        private void dataGridView1_MouseMove(object sender, MouseEventArgs e)
        {
            DataGridView.HitTestInfo hti = this.dataGridView1.HitTest(e.X, e.Y);


            //If the coordinates are in the cell
            if (hti.Type == DataGridViewHitTestType.Cell)
            {
                if (_selecting_index != hti.RowIndex)
                {
                   // this.dataGridView1.Rows[_selecting_index].DefaultCellStyle.BackColor = Color.White;
                    this.dataGridView1.Rows[hti.RowIndex].Selected = true;
                    _selecting_index = hti.RowIndex;
                }
             }
}
among them
this.dataGridView1.MultiSelect = false;
this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list