473,563 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagridview cell background color?

dgk
Is there a way to change the foreground or background color of a
single cell in an unbound datagridview?
Apr 10 '06 #1
11 109582
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.I tem(ColumnIndex , RowIndex).Style .BackColor = Color
DataGridView1.I tem(ColumnIndex , RowIndex).Style .ForeColor = Color

or

DataGridView1.C urrentCell.Styl e.BackColor = Color
DataGridView1.C urrentCell.Styl e.ForeColor = Color
Hope this answers your question.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Apr 10 '06 #2
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?...4-5967be300f0a

I hope this helps,

Cor

"dgk" <No*****@MailsA nonymous.com> schreef in bericht
news:aj******** *************** *********@4ax.c om...
Is there a way to change the foreground or background color of a
single cell in an unbound datagridview?

Apr 10 '06 #3
dgk
On Mon, 10 Apr 2006 10:08:48 +1000, ShaneO <sh******@optus net.com.au>
wrote:
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(ColumnInde x, RowIndex).Style .BackColor = Color
DataGridView1. Item(ColumnInde x, RowIndex).Style .ForeColor = Color

or

DataGridView1. CurrentCell.Sty le.BackColor = Color
DataGridView1. CurrentCell.Sty le.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.
Apr 10 '06 #4
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?...4-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.
Apr 11 '06 #5
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

"ShaneO" <sh******@optus net.com.au> schreef in bericht
news:44******** **************@ news.optusnet.c om.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?...4-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.

Apr 11 '06 #6
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.
Apr 11 '06 #7
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

"ShaneO" <sh******@optus net.com.au> schreef in bericht
news:44******** *************** @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.

Apr 12 '06 #8
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

"ShaneO" <sh******@optus net.com.au> schreef in bericht
news:44******** *************** @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.

Apr 12 '06 #9
dgk
On Wed, 12 Apr 2006 08:48:27 +0200, "Cor Ligthert [MVP]"
<no************ @planet.nl> 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


As the OP, I'd just like to thank everyone for helping. I can't
imagine what I'd do without the folks here.
Apr 12 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3762
by: Michael | last post by:
How can I use onclick to change a table cell background color. I know I can use this.className=? to change the classname. But then I would have to put the code into every single table cell. I read once about using a collection method. Lets say a table has 100 TD Cells with a white background. I want to click on just 1 and then have it...
3
5513
by: Vam | last post by:
Hi, My program makes an HTML report which needs to be easily printable. On this report is a table, and one of the columns in the table needs to express a color. I've done this by setting the background of the cells in that column to their colors (which differ from row to row), but those background colors don't print unless a certain...
6
24767
by: martin1 | last post by:
Hi, all, Is there any way to change DataGridView row color based on different row data? for example, if row data in first column = 1, it is yellow, if it is 2, it is blue, if 3 it is white. That means how to loop DataGridData to get row data, then based on the different data to change row background color? Thanks in advance!
0
2502
by: Thanu | last post by:
Hi, I want to import the background color of cells from excelsheet to Mshflexgrid in Vb6. I already have the code to import the contents from excel to mshflexgrid but i want to import the color also. And the text in some of the cells of mshflexgrid are not Fully visible.only half of the word is visible.How do i format the cells so that i get...
1
6229
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm populating a datagridview from a data table. I would like to set the back ground color of each row based on a column value in that row. If the value of a column for a particular row is set to 1, then the color of the row is red, 2 color of the row is green, 3 color yellow, etc. How would I go about doing this.
1
4626
by: dowlingpc | last post by:
Has anyone discovered a way to control the background color of individual "cells" based on the cells content? When the cell has a negative value or is without content I'd like to change its background color. I'm using XP Pro with all updates and MS-Access 2003 with SP1. Thanks for whatever help you can give - Pat
10
7944
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I understand how to connect a SqlDataSource to a GridView and have a nice data-connected, paginated web page generated with virtually no coding. Starting from that base, I would like to add an extra column to the GridView and do two things: for each row, based on the value of another column, insert a string in the new column cell and set the...
0
3534
by: Chanman | last post by:
I've posted this on the python-excel group, but perhaps people here know what to do. How does one change the cell background color using the xlwt module? I've looked at several tutorials but none show how to change the background color. I've tried the following: badBG = xlwt.Pattern() badBG.SOLID_PATTERN = 0x34 badBG.NO_PATTERN = 0x34
2
9703
by: patrick.waldo | last post by:
Hi all, I am trying to figure out a way to read colors with xlrd, but I did not understand the formatting.py module. Basically, I want to sort rows that are red or green. My initial attempt discovered that text:u'test1.txt' (XF:22) text:u'test2.txt' (XF:15) text:u'test3.txt' (XF:15) text:u'test4.txt' (XF:15) text:u'test5.txt' (XF:23)
0
7882
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5481
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5208
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3634
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2079
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.