Home All Groups Group Topic Archive Search About

Datagridview cell background color?

Author
9 Apr 2006 11:53 PM
dgk
Is there a way to change the foreground or background color of a
single cell in an unbound datagridview?

Author
10 Apr 2006 12:08 AM
ShaneO
dgk wrote:
> Is there a way to change the foreground or background color of a
> single cell in an unbound datagridview?

Use the "Style" property -

DataGridView1.Item(ColumnIndex, RowIndex).Style.BackColor = Color
DataGridView1.Item(ColumnIndex, RowIndex).Style.ForeColor = Color

or

DataGridView1.CurrentCell.Style.BackColor = Color
DataGridView1.CurrentCell.Style.ForeColor = Color


Hope this answers your question.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Author
10 Apr 2006 4:46 PM
dgk
On Mon, 10 Apr 2006 10:08:48 +1000, ShaneO <shane***@optusnet.com.au>
wrote:

Show quoteHide quote
>dgk wrote:
>> Is there a way to change the foreground or background color of a
>> single cell in an unbound datagridview?
>
>Use the "Style" property -
>
>DataGridView1.Item(ColumnIndex, RowIndex).Style.BackColor = Color
>DataGridView1.Item(ColumnIndex, RowIndex).Style.ForeColor = Color
>
>or
>
>DataGridView1.CurrentCell.Style.BackColor = Color
>DataGridView1.CurrentCell.Style.ForeColor = Color
>
>
>Hope this answers your question.
>
>ShaneO
>
>There are 10 kinds of people - Those who understand Binary and those who
>don't.

Yes, that works, thanks.  Amazing how hard that is to find.
Author
10 Apr 2006 6:26 AM
Cor Ligthert [MVP]
DGK,

AFAIK can you as a from a normal textbox, can you not colour the background
of a textbox backgroud.  There is no background at all in those.

You can change the borders.
Here a sample from that on our website.

http://www.vb-tips.com/default.aspx?ID=85cfd8c0-fb6f-46cc-84b4-5967be300f0a

I hope this helps,

Cor



Show quoteHide quote
"dgk" <NoWh***@MailsAnonymous.com> schreef in bericht
news:aj7j3219asos6cnnd0lhhtpkgds7d44hng@4ax.com...
> Is there a way to change the foreground or background color of a
> single cell in an unbound datagridview?
Author
11 Apr 2006 1:41 AM
ShaneO
Cor Ligthert [MVP] wrote:
> DGK,
>
> AFAIK can you as a from a normal textbox, can you not colour the background
> of a textbox backgroud.  There is no background at all in those.
>
> You can change the borders.
> Here a sample from that on our website.
>
> http://www.vb-tips.com/default.aspx?ID=85cfd8c0-fb6f-46cc-84b4-5967be300f0a
>
>
Does anyone know the English translation of what was written above????

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Author
11 Apr 2006 5:55 AM
Cor Ligthert [MVP]
Shane,

There are people who are able to understand what somebody (although it is
written syntactical wrong), and those who don't. It is a fine selection to
select real developers.

>AFAIK can you as a from a normal textbox, can you not colour the background
>of a textbox backgroud.  There is no background at all in those.

I did correct this sentence afterwards to much it had to be.

AFAIK you can from a normal textbox not colour the background. There is no
background at all in those.

Cor

Show quoteHide quote
"ShaneO" <shane***@optusnet.com.au> schreef in bericht
news:443b08ca$0$7602$afc38c87@news.optusnet.com.au...
> Cor Ligthert [MVP] wrote:
>> DGK,
>>
>> AFAIK can you as a from a normal textbox, can you not colour the
>> background of a textbox backgroud.  There is no background at all in
>> those.
>>
>> You can change the borders.
>> Here a sample from that on our website.
>>
>> http://www.vb-tips.com/default.aspx?ID=85cfd8c0-fb6f-46cc-84b4-5967be300f0a
>>
>>
> Does anyone know the English translation of what was written above????
>
> ShaneO
>
> There are 10 kinds of people - Those who understand Binary and those who
> don't.
Author
11 Apr 2006 9:15 PM
ShaneO
Cor Ligthert [MVP] wrote:
> Shane,
>
> There are people who are able to understand what somebody (although it is
> written syntactical wrong), and those who don't. It is a fine selection to
> select real developers.
>
> I did correct this sentence afterwards to much it had to be.
>
> AFAIK you can from a normal textbox not colour the background. There is no
> background at all in those.
>
> Cor
>
Cor, at the risk of maintaining confusion, I still don't know what
you're on about!!

The original poster asked for a way to change the color of the
foreground and background of a DataGridView Cell.  I provided an answer
(which was later acknowledged as being what the original poster was
seeking) but around 6 hours later you posted a reply which looks like
you're saying it can't be done, or at the least, should be done some
other way????

I respect any comments you may have, after all you are a MVP, but PLEASE
carefully explain what point you're trying to make by correcting my
suggestion, if that is what you're trying to do???

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Author
12 Apr 2006 5:48 AM
Cor Ligthert [MVP]
Shane,

Simple, I was reading a DataGrid and did not know that it was done in the
DataGridView in this way. Just word blindness at that moment. Can happen to
me.

I am glad that this is as well done in the datagridview, so now I know that.

But a simple message attending me on this, does more than making a kind of
flame from it.

Thanks,

Cor

Show quoteHide quote
"ShaneO" <shane***@optusnet.com.au> schreef in bericht
news:443c1c5d$0$10676$afc38c87@news.optusnet.com.au...
> Cor Ligthert [MVP] wrote:
>> Shane,
>>
>> There are people who are able to understand what somebody (although it is
>> written syntactical wrong), and those who don't. It is a fine selection
>> to select real developers.
>>
>> I did correct this sentence afterwards to much it had to be.
>>
>> AFAIK you can from a normal textbox not colour the background. There is
>> no background at all in those.
>>
>> Cor
>>
> Cor, at the risk of maintaining confusion, I still don't know what you're
> on about!!
>
> The original poster asked for a way to change the color of the foreground
> and background of a DataGridView Cell.  I provided an answer (which was
> later acknowledged as being what the original poster was seeking) but
> around 6 hours later you posted a reply which looks like you're saying it
> can't be done, or at the least, should be done some other way????
>
> I respect any comments you may have, after all you are a MVP, but PLEASE
> carefully explain what point you're trying to make by correcting my
> suggestion, if that is what you're trying to do???
>
> ShaneO
>
> There are 10 kinds of people - Those who understand Binary and those who
> don't.
Author
12 Apr 2006 6:48 AM
Cor Ligthert [MVP]
ShaneO,

Now I think that I remember me again why I wrote that message.

I thought that Ken had made a complete sample and was searching for that,
but could not find it and that took some time.

Than I remembered me that not existing of a background in a textbox and
found it stupid from myself that I had searched for it.

At that time I was forgotten that you had given an answer

Than I took the sample I had found (which is one of me) and wrote that text.
Although I could not find the right words to describe that and made that
hash text.

Now I know from your message that it is done direct in the cell.

There was not any more intention with that.

If you had asked this direct, than I had probably explained direct. However
flaming me by asking to the public what I had written did not give me a good
thought about you. You could have done that direct to me, and helped me with
that, the sentence was unreadable without investigation.

Cor



Show quoteHide quote
"ShaneO" <shane***@optusnet.com.au> schreef in bericht
news:443c1c5d$0$10676$afc38c87@news.optusnet.com.au...
> Cor Ligthert [MVP] wrote:
>> Shane,
>>
>> There are people who are able to understand what somebody (although it is
>> written syntactical wrong), and those who don't. It is a fine selection
>> to select real developers.
>>
>> I did correct this sentence afterwards to much it had to be.
>>
>> AFAIK you can from a normal textbox not colour the background. There is
>> no background at all in those.
>>
>> Cor
>>
> Cor, at the risk of maintaining confusion, I still don't know what you're
> on about!!
>
> The original poster asked for a way to change the color of the foreground
> and background of a DataGridView Cell.  I provided an answer (which was
> later acknowledged as being what the original poster was seeking) but
> around 6 hours later you posted a reply which looks like you're saying it
> can't be done, or at the least, should be done some other way????
>
> I respect any comments you may have, after all you are a MVP, but PLEASE
> carefully explain what point you're trying to make by correcting my
> suggestion, if that is what you're trying to do???
>
> ShaneO
>
> There are 10 kinds of people - Those who understand Binary and those who
> don't.
Author
12 Apr 2006 1:45 PM
dgk
On Wed, 12 Apr 2006 08:48:27 +0200, "Cor Ligthert [MVP]"
<notmyfirstn***@planet.nl> wrote:

Show quoteHide quote
>ShaneO,
>
>Now I think that I remember me again why I wrote that message.
>
>I thought that Ken had made a complete sample and was searching for that,
>but could not find it and that took some time.
>
>Than I remembered me that not existing of a background in a textbox and
>found it stupid from myself that I had searched for it.
>
>At that time I was forgotten that you had given an answer
>
>Than I took the sample I had found (which is one of me) and wrote that text.
>Although I could not find the right words to describe that and made that
>hash text.
>
>Now I know from your message that it is done direct in the cell.
>
>There was not any more intention with that.
>
>If you had asked this direct, than I had probably explained direct. However
>flaming me by asking to the public what I had written did not give me a good
>thought about you. You could have done that direct to me, and helped me with
>that, the sentence was unreadable without investigation.
>
>Cor

As the OP, I'd just like to thank everyone for helping. I can't
imagine what I'd do without the folks here.
Author
14 Apr 2006 12:56 AM
ShaneO
Cor Ligthert [MVP] wrote:
Show quoteHide quote
> ShaneO,
>
> Now I think that I remember me again why I wrote that message.
>
> I thought that Ken had made a complete sample and was searching for that,
> but could not find it and that took some time.
>
> Than I remembered me that not existing of a background in a textbox and
> found it stupid from myself that I had searched for it.
>
> At that time I was forgotten that you had given an answer
>
> Than I took the sample I had found (which is one of me) and wrote that text.
> Although I could not find the right words to describe that and made that
> hash text.
>
> Now I know from your message that it is done direct in the cell.
>
> There was not any more intention with that.
>
> If you had asked this direct, than I had probably explained direct. However
> flaming me by asking to the public what I had written did not give me a good
> thought about you. You could have done that direct to me, and helped me with
> that, the sentence was unreadable without investigation.
>
> Cor
>

Cor, I'm sorry if it appeared as a "Flame".  It was my poor attempt at
humour, which obviously does not translate well in a written message.

Best Regards,

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Author
14 Apr 2006 5:36 AM
Cor Ligthert [MVP]
Shane,

No problem. exactly as you wrote.

Cor

Show quoteHide quote
"ShaneO" <shane***@optusnet.com.au> schreef in bericht
news:443ef359$0$10673$afc38c87@news.optusnet.com.au...
> Cor Ligthert [MVP] wrote:
>> ShaneO,
>>
>> Now I think that I remember me again why I wrote that message.
>>
>> I thought that Ken had made a complete sample and was searching for that,
>> but could not find it and that took some time.
>>
>> Than I remembered me that not existing of a background in a textbox and
>> found it stupid from myself that I had searched for it.
>>
>> At that time I was forgotten that you had given an answer
>>
>> Than I took the sample I had found (which is one of me) and wrote that
>> text. Although I could not find the right words to describe that and made
>> that hash text.
>>
>> Now I know from your message that it is done direct in the cell.
>>
>> There was not any more intention with that.
>>
>> If you had asked this direct, than I had probably explained direct.
>> However flaming me by asking to the public what I had written did not
>> give me a good thought about you. You could have done that direct to me,
>> and helped me with that, the sentence was unreadable without
>> investigation.
>>
>> Cor
>>
>
> Cor, I'm sorry if it appeared as a "Flame".  It was my poor attempt at
> humour, which obviously does not translate well in a written message.
>
> Best Regards,
>
> ShaneO
>
> There are 10 kinds of people - Those who understand Binary and those who
> don't.