Home All Groups Group Topic Archive Search About

Highlighting text in DataGridView

Author
31 May 2006 9:15 PM
sh
How can I highlight the text in a cell, as if it had been selected with
the mouse?

I have a validation routine that checks the data in each column. If a
cell fails the validation, I show a MessageBox with an error message. I
then want to highlight the bad data. But I can't seem to do that.

I don't want to change the background color, nor the foreground color. I
just want to highlight it as if it had been selected by mouse.

In a TextBox, there is SelectionStart and SelectionLength. Is there
something similar in a DataGridView?

Thanks in advance.

Author
1 Jun 2006 1:26 AM
ronchese
..Net 2005:

DataGridView1.Rows(0).Cells(0).Style.BackColor = Color.Yellow

[]s

Cesar


Show quoteHide quote
"sh" <sham***@prupipe.com> wrote in message news:7Infg.299$jB5.287@newsread3.news.pas.earthlink.net...
> How can I highlight the text in a cell, as if it had been selected with
> the mouse?
>
> I have a validation routine that checks the data in each column. If a
> cell fails the validation, I show a MessageBox with an error message. I
> then want to highlight the bad data. But I can't seem to do that.
>
> I don't want to change the background color, nor the foreground color. I
> just want to highlight it as if it had been selected by mouse.
>
> In a TextBox, there is SelectionStart and SelectionLength. Is there
> something similar in a DataGridView?
>
> Thanks in advance.