Mahobo Mahobo - 1 month ago 6
C# Question

Error CS1674 trying to open second form

I'm sure, this is a total newbie question, but I'm hanging for hours now...

My main form should have a method that opens a second form with a textbox. Just to have a kind of messagebox with scrollbar. I know there are lots of examples out there, but they are all too extensive for my needs. So here is my code so far:

private void ShowBox (string info)
{
if (info != "")
{
using (var form = new Message())
{
// work to do
}
}
}

public partial class Message : Form
{
public Message()
{
InitializeComponent();
say.Text = "OK";
}
}


Message is my 2nd form. I receive CS1674 (type used in a using statement must be implicitly convertible to 'System.IDisposable') error on the using line.
I already took this as reference Opening and closing form2 from form1 C# but I don't see the difference to my code.
What am I doing wrong?

Answer

Message probably resolves as System.Windows.Forms.Message which is a structure.

Ctrl+Click on your usage of new Message() will jump to the declaration.

Comments