473,654 Members | 3,097 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

changing the color of the entire row in datagrid when a cell in the row has value greater than zero

hello everybody,

I am having a datagrid which has data regarding customers. it has a
penalty column, and i want to show the entire record of the customer
in red whose penalty is greater than zero.

i have looked into the other messages which guide to override the
paint procedure of the datagrid, make a new class etc.

i am not able to understand the exact way of doing the mentioned
things.

i'll be thankful if somebody pours in some help.

hemant.
Nov 21 '05 #1
2 1337
Hi,

Maybe selecting the row will work for you.

Dim conn As SqlConnection

Dim strConn As String

Dim strSQL As String

Dim da As SqlDataAdapter

Dim ds As New DataSet

strConn = "Server = (local);"

strConn &= "Database = NorthWind;"

strConn &= "Integrated Security = SSPI;"

conn = New SqlConnection(s trConn)

da = New SqlDataAdapter( "Select * From Products", conn)

da.Fill(ds, "Products")

DataGrid1.DataS ource = ds.Tables("Prod ucts")

For x As Integer = 0 To ds.Tables("Prod ucts").Rows.Cou nt - 1

Dim dr As DataRow = ds.Tables("Prod ucts").Rows(x)

If CInt(dr.Item("U nitsInStock")) < 5 Then DataGrid1.Selec t(x)

Next

Ken

-----------------------

"hemant" <he********@yah oo.com> wrote in message
news:1b******** *************** ***@posting.goo gle.com...
hello everybody,

I am having a datagrid which has data regarding customers. it has a
penalty column, and i want to show the entire record of the customer
in red whose penalty is greater than zero.

i have looked into the other messages which guide to override the
paint procedure of the datagrid, make a new class etc.

i am not able to understand the exact way of doing the mentioned
things.

i'll be thankful if somebody pours in some help.

hemant.
Nov 21 '05 #2
"hemant" <he********@yah oo.com> wrote in message
news:1b******** *************** ***@posting.goo gle.com...
hello everybody,

I am having a datagrid which has data regarding customers. it has a
penalty column, and i want to show the entire record of the customer
in red whose penalty is greater than zero.

i have looked into the other messages which guide to override the
paint procedure of the datagrid, make a new class etc.

i am not able to understand the exact way of doing the mentioned
things.

i'll be thankful if somebody pours in some help.

hemant.


I think if selecting the whole row is no good it'd be a hell of a lot easier
if you just highlit the textbox has the negative amount in it.
Check out george shepherd's faq site.
The datagrid section might have some ideas in it for you.

I suppose you could maybe mark an error in the row selector thing.

--
Regards,
Andy O'Neill
Nov 21 '05 #3

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

Similar topics

2
11037
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic SFSB and, from there, to the database. On the front end, all cells appear as text fields. However, for certain cells, when the user clicks on the cell, the text field turns into a drop-down field (i.e. Select object), defaulting to the value...
15
2337
by: | last post by:
Just about finished with an include modual that allows a user to select a color. Completely dynamic. all you have to do is include the script and run the main trigger script. One problem with the event modual is the fact that it resets events for all TD's. not sure how to specify to cascade down through just the created table. Any ideas? Feel free to use this where ever you wish as long as you give me credit. this was a few weeks of...
4
1911
by: David Krmpotic | last post by:
Hello, Can please tell me how to do it ? This should be simple, because I'd think it's used a lot.. but in reality is not that simple and there is at least 50 topics about it in newsgroups, but the problem is that people see the question and just write about overriding OnPaint or pointing to the syncfusion site without reading the question.. it's coloring the entire row, not just one cell.. I can't believe it, but there is so many...
0
1147
by: enahar | last post by:
I want to validate a cell wheather a value is greater than 0 or not.If value is greater than 0 then I want to show messagebox and focus back the same cell else move to the other cell. I am writing the following code on the column_chnaging and tetbox validating events, but nothing works .If value is greater than 0 then it pops up the message but focus moves to the other cell.
1
1972
by: Shawn Benson | last post by:
I have a Windows form where a user enters an order number which returns a dataset that is bound to a datagrid. The problem is when a user clicks on a cell in the datagrid, then enters another order to get information for, everything is updated with the new data except the cell in the grid that was selected. This behavior does not occur when a table style is not applied to the datagrid. How do I refresh the datagrid so that the cell in...
3
15396
by: Mad Scientist Jr | last post by:
Can someone post a clear example of how to change the background color of an individual datagrid cell for a Windows desktop app? (preferably in vb.net) I found some code on how to do this when the user clicks on the cell: Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged DataGrid1.Controls(DataGrid1.CurrentCell.ColumnNumber + 2).BackColor =...
4
1967
by: John Smith | last post by:
Hi All; I am using the HeaderAndDataAlignColumn class from Ken Tucker. I have customized it for a wider row. I reposition the DrawString method so the text is centered vertically in the row. My problem now is that on ReadOnly cells the shaded background is not at the top of the cell. I adjust the rectangle Height so that the shading does not drop into the next row.
2
2377
by: chris357 | last post by:
I am new to .Net. Currently I am creating a windows application. I would like to know how to change the row color in a datagrid based on the value present in the cell in datagrid. For eg:- in my datagrid there are 2 fields called product name and quatity. If the quantity is greater than 20 then that entire row should be in red color. Pls help.
9
2713
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
0
8375
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
8815
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
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...
0
8593
tracyyun
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...
0
7306
agi2029
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...
1
6161
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
5622
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1593
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.