473,804 Members | 3,037 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I color a cell in my datagrid depending on it's value and another value in other column

Hi

I want to compare 02 columns in my datagrid and for example if my column5 <
column6 I want to color my columns 5 and 6.
This is my code and I'm not able to get the value of column6 in my Paint
method

thank you for your help

public class DataGridColored TextBoxColumn : DataGridTextBox Column
{
protected override void Paint(System.Dr awing.Graphics g,
System.Drawing. Rectangle bounds, System.Windows. Forms.CurrencyM anager
source, int rowNum, System.Drawing. Brush backBrush, System.Drawing. Brush
foreBrush, bool alignToRight)
{
try
{
int col = this.DataGridTa bleStyle.GridCo lumnStyles.Inde xOf(this);
if (col == 5)
{
object Obj1 = this.GetColumnV alueAtRow(sourc e, rowNum);
int ID1 = Convert.ToInt32 (Obj1.ToString( ));

// Need help here
object Obj2 = ... Get object from column 6 how ?
int ID2 = Convert.ToInt32 (Obj2.ToString( ));

if (ID1 > ID2)
{
foreBrush = new SolidBrush(Colo r.Red);
}
}
}
finally
{
// color cell in col 5
base.Paint(g, bounds, source, rowNum, backBrush, foreBrush,
alignToRight);

// how to color the cell in color 6 ?
...
}
}
}
Nov 17 '05 #1
0 1135

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

Similar topics

1
4645
by: VM | last post by:
Is it possible for the bound data in a web datagrid to be displayed in links? The grid will show the client's first name and last name and, when the user clicks on the first or last name, I want to get the cell the user clicked (thus getting the client he chose), and take the user to another separate page that will show that client's complete information. It doesn't really have to be like that (there could be another extra column - as a...
4
12822
by: Dave Petersen | last post by:
How do I set the color of a particular column in my C# winforms datagrid? Thanks, Dave
2
1788
by: Niccolo | last post by:
hi: I have this problem. I have to fill a datagrid with 2 columns. One column is non editable (header property). The other column (header value) instead is editable. Some cells of this second column could be textbox and some could be combobox (depending of the value). Have you any idea to solve this problem? The data source is an arrylist.
6
11540
by: Barney Nicholls | last post by:
I have a datagrid and want to change the background color of the end column to denote that it is the only column that is not read only. I still want this column to be editable. I've found examples that let you change the background color of the cell but it but the cell no longer appears to be editable.
0
1516
by: Dan Hartshorn | last post by:
VS.NET 2003, C#, Windows Server 2003. I have a datagrid and I want the last column to be either an EditCommandColumn or a template column, depending on a value I have. The value changes for each row. So some rows will have an EditCommandColumn, others just a text message in the last column. Is this possible? I am already using the ItemDataBound method to perform some function on each row, but I can't seem to change the datagrid's column...
3
1093
by: brix_zx2 | last post by:
I'm writing a program in VB .NET 2k3, I have a datagrid bound to a database (Access 2002). Does anyone have info or know where I can go to change the color of a row based on the value in one column? I have found stuff on alternating colors and all that good stuff but nothing that I need. Thanks
10
4957
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than the column order of the datatable). I also allow the user to click on a column header to sort the datagrid by that column. I need to identify the row and column in the datatable when the user clicks on a cell in the datagrid. Using the...
0
1299
by: theintrepidfox | last post by:
Dear Group I really need your help on this issue. I've a datagrid which source is a dataview based on a dataset. The columns of the grid are datagridtextbox columns created like the following example: Dim Column1 As New DataGridTextBoxColumn With Column1
0
1199
by: joinzulfi | last post by:
Dear fellows! I have designed a form having SaleMasterTable and SaleDetailTable. SaleDetailTable is Bounded with DataGrid. Now I want that if in2nd Column's cell (it is combobox) value is changed then as a result of this change in 3rd column's cell (it is textbox) value is inserted from another table in database named Product.
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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,...
0
10326
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
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,...
1
7615
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5520
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...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
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
3
2990
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.