Hi All,
I wish to change the background colour and contents of a datagrid cell based
on the value of one of the columns on a per row basis. So, for example, if
column A's value is 1, column 2 should be red with 'No' written in it. If
column A's value is 0, column 2 should be green with 'Yes' written in it.
Can anyone advise how I could achieve this? (I know how to display/populate
the datagrid).
Thanks,
Simon. 2 1125
Simon,
Most flexible way is to use ItemDataBound event. Event handler gets
reference to an item which represents the grid row. You have access to the
item cells (row columns) and can get/set cells properties programmaticall y.
Eliyahu
"Simon Harris" <to***********@ makes-you-fat.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. Hi All,
I wish to change the background colour and contents of a datagrid cell
based on the value of one of the columns on a per row basis. So, for example, if column A's value is 1, column 2 should be red with 'No' written in it. If column A's value is 0, column 2 should be green with 'Yes' written in it.
Can anyone advise how I could achieve this? (I know how to
display/populate the datagrid).
Thanks, Simon.
Thank you! :)
"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:O$******** ******@TK2MSFTN GP09.phx.gbl... Simon,
Most flexible way is to use ItemDataBound event. Event handler gets reference to an item which represents the grid row. You have access to the item cells (row columns) and can get/set cells properties programmaticall y.
Eliyahu
"Simon Harris" <to***********@ makes-you-fat.com> wrote in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. Hi All,
I wish to change the background colour and contents of a datagrid cell based on the value of one of the columns on a per row basis. So, for example, if column A's value is 1, column 2 should be red with 'No' written in it. If column A's value is 0, column 2 should be green with 'Yes' written in it.
Can anyone advise how I could achieve this? (I know how to display/populate the datagrid).
Thanks, Simon.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jeff Cook |
last post by:
Hi
I have a DataGrid that I am using to display a .xml file (that has a schema
in a .xsd), like this:-
ds.ReadXmlSchema(sDataPath + "Data.xsd");
ds.ReadXml(sDataPath + "Data.xml", XmlReadMode.InferSchema);
grdXXXX.DataSource = ds;
FormatGridColumns(grdXXXX, ds.Tables); // my routine below.
|
by: J.B |
last post by:
I have a datagrid that will display different datasets, (it runs
different sprocs based on a value in the querystring) but it will
always return 6 columns. The 5th and 6th columns are always Date and
Currency format, all others are strings.
I'd like to build one datagrid to handle this datagrid dynamically. I
have it working now, all except the formatting of the 5th (Date) and
6th (Currency) columns.
Since the headers for those...
|
by: Sebi |
last post by:
Hello all
is it possible to add a checkbox in a DataGrid for
Boolean Data?
Thanks in advance
|
by: hope |
last post by:
Hi,
How can I format a string field using Data Formatting Expression property in
datagrid?
For example: format last name from BROWN to Brown.
Thanks
|
by: DraguVaso |
last post by:
Hi,
I'm looking for a nice way to format the cell of my datagrid according to
some predefined 'rules'. I found a lot on the site of George shepherd, but
it wasn't really what I was looking for:
I found there: How can I change the font used in a Gridcell on a cell by
cell or row by row basis. Wih this code I am able to change the
Font/Background/... based on the position of the field (column and row). The
problem is: it only changes...
| |
by: Starbuck |
last post by:
Hi All
Using VB.Net with a datagrid which shows a column called status - the values
can be 0 to 6.
Is there anyway of formatting this column show the numeric value is
translated to a more readable test one.
Example
0 to New Job
6 to Complete
|
by: steve |
last post by:
Hi,
First my apologies for double-posting but I am not sure wether this is a
VB.Net or TSQL problem.
I have the following problem:
I generate a T-SQL string in order to fill my Dataset and consecuently a
Datagrid.
However on the date_time column only the date part is showing : e.g.
2004-08-14
|
by: Randall Parker |
last post by:
Suppose you want to do either of these:
A) Set display properties (e.g. color or boldness of text) of a cell based on a value
of another cell in the same row.
B) Set the display properties of a whole row based on values of one or more cells in
that row.
Well, these seem like reasonable things to want to do. If one was writing one's own
code to spit out HTML table tr and td tags like in days of old (like, say, 6 years
|
by: cindy |
last post by:
I have a dynamic datagrid. I have custom classes for the controls
public class CreateEditItemTemplateDDL : ITemplate {
DataTable dtBind;
string strddlName;
string strSelectedID;
string strDataValueField;
string strDataTextField;
public CreateEditItemTemplateDDL(string DDLName,string DataValueField,string
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |