0

Hi I created an error message that contains each value of whether or not is was a pass or fail. I would like each entry to change color based on Passed = green and pail = red.

Example:

  1. Fare: Passed
  2. Name: Passed
  3. Date: Failed
  4. Address: Failed
  5. Age: Passed

This gets displayed in an output message box, currently

msgBox(errorMessage)

When this gets displayed I like the fails background to be red and the passed to have a green background. Currently I am still considered new to VB.Net I know how to do for mouse hovers and mouseleaves. I am assuming I need to make an event similar to those.

Thank you For your help.

  • 1
    That's not an option, you'll need at least a RichTextBox to display text with a choice of colors. – Hans Passant Nov 04 '14 at 22:48
  • If you are trying to present something like Data Validation results, consider the [ErrorProvider](http://i.imgur.com/mu68SYI.jpg) component which will display a message when you hover over an item. – Ňɏssa Pøngjǣrdenlarp Nov 04 '14 at 23:54

1 Answers1

2

You're not going to do that with MsgBox or MessageBox.Show, which MsgBox calls internally. You're going to have to create your own form and then either add one Label for each line, in which case you can set the ForeColor for each one, or else draw the text yourself using GDI+. If you do go the Label route, you'll probably want to use a TableLayoutPanel or FlowLayoutPanel to keep them aligned correctly.

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46
  • Can't we make our own message box? And change the colours of the text that way? –  Nov 04 '14 at 22:10
  • Um, that's what I said. What exactly would your own message box be if not a form of your own creation? What do you think it is that `MsgBox` and `MessageBox.Show` actually display? It's a form. You need to create the form yourself because the one that those methods display cannot be manipulated to change the text colour. – jmcilhinney Nov 04 '14 at 22:28