Solved

How to color Rows in a DataGridView with two dataset merged.....

Posted on 2008-10-29
2
486 Views
Last Modified: 2013-12-17
Hi

I want to color my rows in datagridview, i want to color rows only 1 of the dataset not all og the rows, color only rows on one of the datasets....
if (chkReconsiled.Checked)
            {
                btnUndoImport.Visible = false;
                lblcannotundo.Visible = true;
                lblcannotundo.Text = "Kan ikke oppheve avstemte import";
                myDsFilesToUndo.Merge(importedReconsiledfiles);
                gridImports.DataSource = myDsFilesToUndo.Tables[0];
 
                //importedReconsiledfiles.Tables[0].RowsDefaultCellStyle.BackColor = Color.AliceBlue;
                //gridImports.RowsDefaultCellStyle.BackColor = Color.AliceBlue;
            
                ////gridImports.DataSource = importedReconsiledfiles.Tables[0];
                //gridImports.RowsDefaultCellStyle.BackColor = Color.White;
                //gridImports.ReadOnly = true;
                //gridImports.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
                //gridImports.MultiSelect = false;
 
            }
            if (!chkReconsiled.Checked)
            {
                btnUndoImport.Visible = true;
                lblcannotundo.Visible = false;
                gridImports.DataSource = myDsFilesToUndo.Tables[0];
                gridImports.RowsDefaultCellStyle.BackColor = Color.White;
                gridImports.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            }

Open in new window

0
Comment
Question by:Adnan
2 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 22830840
Can you see from the data from which recordset the record comes ? I mean: is there a column which will tell us this comes from dataset1, this from 2

If so, you can check the following event
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
 
Dim intPrice As Decimal = e.Item.Cells(1).Text ' thsi is price column no.
If intPrice > 100 Then
Dim i As Int16
For i = 0 To DataGrid1.Columns.Count
e.Item.Cells(i).BackColor = System.Drawing.Color.Red ' the row is in color red
Next
 
End If
End If
End Sub

Open in new window

0
 

Author Closing Comment

by:Adnan
ID: 31511136
nice ;)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question