I have developed an application in vb.net with MS access. In a form I have a Datagridview and I retrieve the data by databindingsource.
I am copying the data from datagridview to textbox and then to another table in database.
I want- after being copied the color of selected row should be changed , so next time whenever I retrive data in datagridview, the color of selected rows should have been changed.
Is this possible?
Satyam_1 0 Junior Poster
Recommended Answers
Jump to PostExample. Iterate over all columns to change the entire row.
dgvNames.Rows(row).Cells(0).Style.BackColor = Color.Thistle
Jump to PostSo that the next time I retrieve the data, the rows that I have viewed (changes made) will show the red color.The remaining will show the default color.
In order to do that you will have to add a column to the database table indicating that the row …
Jump to PostAll that would require is adding a boolean value, True would indicate alternate colouring for the row.
Jump to PostYou add a column named something like
Changed
orAlternateColour
then you step through all of the rows in the grid and doIf Changed Then For Each cell In dgvData.Rows(row).Cells cell.Style.BackColor = Color.Red Next End If
Just replace
Changed
with an expression …
Jump to PostPut it immediately after the code that either binds the table to the grid, or the code that manually populates the grid from the table. Using the Microsoft PUBS database the following code displays the Authors table with all last names starting with "S" in red.
Dim …
All 20 Replies
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Minimalist 96 Posting Pro
Satyam_1 0 Junior Poster
Minimalist 96 Posting Pro
Santanu.Das 125 Santanu Das
Satyam_1 0 Junior Poster
Santanu.Das 125 Santanu Das
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Satyam_1 0 Junior Poster
Santanu.Das 125 Santanu Das
Satyam_1 0 Junior Poster
Minimalist 96 Posting Pro
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Satyam_1 0 Junior Poster
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Satyam_1 0 Junior Poster
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Satyam_1 0 Junior Poster
Reverend Jim 5,259 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Satyam_1 0 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.