MessageBox with text color and link - c#

How I can make message box as like this in picture:
in C# WPF
http://www7.0zz0.com/2013/08/27/10/853934885.png

You can create the icon with MessageBoxIcon.Information. If you want to create a link, you should probably create a different form and send data between your form1 and form2.

Related

Hide button menu strip when I open another form c#

I have a great application with an initial form. This form has a menu strip with four "buttons" like this:
My Form with menu strip
This main form contains another form with more applications. What I want to do is when I open another form (application) I want to hide only the menu strip item called "Cambiar Empresa".
What I have thought is to make visibility false when I am in another form, but I cannot call this form because there is a problem of circular dependence.
How could I do this?
EDIt:
The second form is in the pink line and the main form is in the blue line:
Estructure
Thanks in advance!

How do I display an image when I click a button (Like MessageBox.Show)?

How do I display an image when I click a button ? Like MessageBox.Show, it will open a new window. Unfortunately MessageBox only do it on text. how about images ?
As a suggestion how about if you:
Create a new windows form instead with PictureBox inside.
Load the image on the PictureBox before showing it
Use Form.ShowDialog(this)
Return DialogResult upon clicking the buttons you define in your windows form
we can create image (or) pic to be clickable links by using this code
<a href="http://www.w3.org"><img src="w3c_home.gif"
alt="World Wide Web Consortium Home"
width="72"height="46"border="0"/></a>see in this blog
http://www.facebookliteapp.com/2015/06/facebook-lite-for-Android-pc-laptops.html

Add button to copy text in MessageBox

I have a program that contains a list of names, and a button that displays a random name in a MessageBox. Is there any way I can add a button "Copy" next to the OK to the MessageBox, that when clicked copies the name and then closes?
If the above isn't possible, is there a way to enable copying the text in a MessageBox?
Thank you.
edit: My users won't understand Ctrl+C, Highlight and Right Click > Copy is what I'm looking for (if a Copy button isn't possible)
If a user presses Ctrl-C while the MessageBox has focus, the message, the MessageBox caption and the MessageBoxButtons labels are copied to the clipboard.
I googled your title and found this..
Or if you really need a button that says copy you can create your own MessageBox with a new windows form and then do what you want with the buttons. Open it like this to keep the MessageBox feel :
var myMessageBox = new CustomMessageBox();
myMessageBox.ShowDialog();
It sounds like maybe you are looking for the Clipboard class.
Clipboard.SetText(variableWithValue);
There is also another answer here about manipulating the contents of a Message Box.
It also might be easier to simply make a modal dialog that emulates a MessageBox without actually using the MessageBox class.

Get current MessageBox

I have a large application with several forms, any of them could get a MessageBox (MessageBox.Show()) that is modal and locks the form.
On activation of another form I now need to find this MessageBox and bring the form that has this MessageBox to front. Is there any way to check this?
I know about the Application.OpenForms property, maybe there is something like this for MessageBox?
Edit1 : For example, say that we open Winform1, then a event in Winform1 will go to the mainController that opens Winform2. Lateron Winform1 is getting a MessageBox.Show, But its fully possible to bring Winform2 to front(above Winform1). So now I need to react to the Winform.Activated to check if there is any MessageBox.Show and if so, bring this form that holds the MessageBox to front.
You could find them by using Application.OpenForms like this:
foreach (Form f in Application.OpenForms)
{
if (f.Visible && ! f.CanFocus)
{
// whatever...
}
}
Or: use a different approach altogether:
Make all your forms handle Application.EnterThreadModal and Application.LeaveThreadModal, so that when the app goes modal while that form is current, you add that form onto a list so you can keep track of it, and remove it from the list when it leaves modal...
Then all you need to do is query that list to see if any forms have a modal dialog box open.
Try using one of the Show methods that takes an owner:
MessageBox.Show(this, "My Message");
I tested this on .NET 4 / Windows 7, and when the message box is opened it brings its owner to the front.

C# - Use form instead of messagebox

I am working on an application for work and I need a customized messagebox to appear. I have created a simple form called Alert.cs that I have styled the way I want and added one button with a click method of this.Close(). now I want it to behave exactly like a standard messagebox.show(). I have the form showing but when I use the standard messagebox.show("text of alert") it waits to continue operation until the user click 'OK', this is what I want the form to do.
Use Form.ShowDialog();. This allows the form to act the same way as a MessageBox in the sense that it retains focus until closed.
You will need to implement a static method for your Alert class if you want the exact MessageBox-like behaviour.
public static DialogResult Show(string text)
{
Alert form = new Alert(text);
return form.ShowDialog();
}
Now you can use the form by calling:
Alert.Show("my message");
You can use a modal windows form. Something like
Form frm = new Form();
frm.ShowDialog(this);
See Form.ShowDialog Method
Shows the form as a modal dialog box
with the currently active window set
as its owner.
Displaying Modal and Modeless Windows Forms
You don't write how you currently display your Alert Form, but calling
alert.ShowDialog();
instead of alert.Show() should do the trick.
The ShowDialog that takes an owner is an even better alternative:
alert.ShowDialog(owner);

Categories

Resources