?
Solved

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

Posted on 2008-10-29
2
Medium Priority
?
490 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

801 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