Buggy Color Datagridview VB.NET





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















Hello i have some application, but the application is buggy in the Data Grid View. The Data Grid View is set automatically if change the color there will be all Data Grid View is full of color. But my Application is buggy some Cells, There is no color like in the image below:
https://i.stack.imgur.com/ECw1D.png



My code for that is



Private Sub DGV_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DGV.CellFormatting
If DGV.Rows.Count > 0 Then
For Each row As DataGridViewRow In DGV.Rows
Dim tgl As String = row.Cells(2).Value
Dim tgm As Date = Date.ParseExact(tgl, "dd-MM-yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo)
If tgm < Date.Now Then
row.DefaultCellStyle.BackColor = Color.Red
End If
Next
End If
End Sub


Please help! Im so dizzy with this!



Thank you!










share|improve this question




















  • 2





    You don't loop through the entire grid in that event handler. The whole point is that that event is raised when a specific cell is being formatted so you operate on just that one cell. That event will be raised at least once for every cell in the grid so that's how every cell gets processed. The e parameter tells you what cell is currently being formatted. Maybe take a look at some examples of using that event.

    – jmcilhinney
    Jan 3 at 13:00


















0















Hello i have some application, but the application is buggy in the Data Grid View. The Data Grid View is set automatically if change the color there will be all Data Grid View is full of color. But my Application is buggy some Cells, There is no color like in the image below:
https://i.stack.imgur.com/ECw1D.png



My code for that is



Private Sub DGV_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DGV.CellFormatting
If DGV.Rows.Count > 0 Then
For Each row As DataGridViewRow In DGV.Rows
Dim tgl As String = row.Cells(2).Value
Dim tgm As Date = Date.ParseExact(tgl, "dd-MM-yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo)
If tgm < Date.Now Then
row.DefaultCellStyle.BackColor = Color.Red
End If
Next
End If
End Sub


Please help! Im so dizzy with this!



Thank you!










share|improve this question




















  • 2





    You don't loop through the entire grid in that event handler. The whole point is that that event is raised when a specific cell is being formatted so you operate on just that one cell. That event will be raised at least once for every cell in the grid so that's how every cell gets processed. The e parameter tells you what cell is currently being formatted. Maybe take a look at some examples of using that event.

    – jmcilhinney
    Jan 3 at 13:00














0












0








0








Hello i have some application, but the application is buggy in the Data Grid View. The Data Grid View is set automatically if change the color there will be all Data Grid View is full of color. But my Application is buggy some Cells, There is no color like in the image below:
https://i.stack.imgur.com/ECw1D.png



My code for that is



Private Sub DGV_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DGV.CellFormatting
If DGV.Rows.Count > 0 Then
For Each row As DataGridViewRow In DGV.Rows
Dim tgl As String = row.Cells(2).Value
Dim tgm As Date = Date.ParseExact(tgl, "dd-MM-yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo)
If tgm < Date.Now Then
row.DefaultCellStyle.BackColor = Color.Red
End If
Next
End If
End Sub


Please help! Im so dizzy with this!



Thank you!










share|improve this question
















Hello i have some application, but the application is buggy in the Data Grid View. The Data Grid View is set automatically if change the color there will be all Data Grid View is full of color. But my Application is buggy some Cells, There is no color like in the image below:
https://i.stack.imgur.com/ECw1D.png



My code for that is



Private Sub DGV_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DGV.CellFormatting
If DGV.Rows.Count > 0 Then
For Each row As DataGridViewRow In DGV.Rows
Dim tgl As String = row.Cells(2).Value
Dim tgm As Date = Date.ParseExact(tgl, "dd-MM-yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo)
If tgm < Date.Now Then
row.DefaultCellStyle.BackColor = Color.Red
End If
Next
End If
End Sub


Please help! Im so dizzy with this!



Thank you!







vb.net datagridview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 7:26









Mary

4,0712921




4,0712921










asked Jan 3 at 6:14









RaiRai

12




12








  • 2





    You don't loop through the entire grid in that event handler. The whole point is that that event is raised when a specific cell is being formatted so you operate on just that one cell. That event will be raised at least once for every cell in the grid so that's how every cell gets processed. The e parameter tells you what cell is currently being formatted. Maybe take a look at some examples of using that event.

    – jmcilhinney
    Jan 3 at 13:00














  • 2





    You don't loop through the entire grid in that event handler. The whole point is that that event is raised when a specific cell is being formatted so you operate on just that one cell. That event will be raised at least once for every cell in the grid so that's how every cell gets processed. The e parameter tells you what cell is currently being formatted. Maybe take a look at some examples of using that event.

    – jmcilhinney
    Jan 3 at 13:00








2




2





You don't loop through the entire grid in that event handler. The whole point is that that event is raised when a specific cell is being formatted so you operate on just that one cell. That event will be raised at least once for every cell in the grid so that's how every cell gets processed. The e parameter tells you what cell is currently being formatted. Maybe take a look at some examples of using that event.

– jmcilhinney
Jan 3 at 13:00





You don't loop through the entire grid in that event handler. The whole point is that that event is raised when a specific cell is being formatted so you operate on just that one cell. That event will be raised at least once for every cell in the grid so that's how every cell gets processed. The e parameter tells you what cell is currently being formatted. Maybe take a look at some examples of using that event.

– jmcilhinney
Jan 3 at 13:00












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54017180%2fbuggy-color-datagridview-vb-net%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54017180%2fbuggy-color-datagridview-vb-net%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

Npm cannot find a required file even through it is in the searched directory