Solved

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

Posted on 2008-10-29
2
489 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 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

695 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