Bind a Textbox which is contained in a Groupbox

I have a Winforms App with a Groupbox which, in turn, contains a textbox. I find that the textbox will not bind when enclosed in the Groupbox, even though it does bind (correctly) when not contained in the Groupbox.

This is the case whether the binding is expressed in the Properties window or in the code.
Has anyone else experienced this behavior or have an explanation for it?

Note that whether the textbox is enabled or not makes no difference.

From the Windows Designer.vb file:

    Me.HearingInfoGroupBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.HearingInfoGroupBox.Location = New System.Drawing.Point(17, 109)
    Me.HearingInfoGroupBox.Name = "HearingInfoGroupBox"
    Me.HearingInfoGroupBox.Size = New System.Drawing.Size(333, 152)
    Me.HearingInfoGroupBox.TabIndex = 47
    Me.HearingInfoGroupBox.TabStop = False
    Me.HearingInfoGroupBox.Text = "Hearing Info"
    Me.HearingTypeTextBox.Enabled = False
    Me.HearingTypeTextBox.Location = New System.Drawing.Point(112, 86)
    Me.HearingTypeTextBox.Name = "HearingTypeTextBox"
    Me.HearingTypeTextBox.Size = New System.Drawing.Size(204, 20)
    Me.HearingTypeTextBox.TabIndex = 59

And from the Form code file (or the designer, if implemented through the Properties window):

    Me.HearingTypeTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.JuvPlacementDataBindingSource, "HearingType", True))

Winforms timer reduce window size

I have a little problem when I use the timer from the System.Windows.Forms.Timer class. Currently I am making a simple text editor and I want to create shortcuts to save, open,… files. For that I use the timer class which simply checks in an interval if a special key combination was pressed. If yes it acts like the button(new, open,..) was pressed. Now the thing is that the key combinations just work fine but the window of the program looks ugly. The size of the menu get reduced and I don’t know why that happens. I show you one picture of the normal look and one when the timer is running. It seems that the STA thread (the timer) makes the problem, but I am not sure why. Here the pictures:

Without timer:
enter image description here

With timer:
enter image description here

My code:

public MainWindow()

    this.textChanged = false;
    this.fileName = "Untitled";
    this.Text = "TextEditor" + " - " + this.fileName;

    this.shortcutPressed = false;
    this.timer = new System.Windows.Forms.Timer();
    this.timer.Interval = 1;
    this.timer.Tick += new EventHandler(this.CheckForShortCut);
    this.timer.Enabled = true;

private void CheckForShortCut(object sender, EventArgs e)
    if ((Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) && this.shortcutPressed == false)
        if (Keyboard.IsKeyDown(Key.N))
            this.shortcutPressed = true;
            this.NewToolStripMenuItem_Click(this, new EventArgs());
            this.shortcutPressed = false;

C# WinForms How to add Chart to Panel?

I’m trying to add dynamically charts to a panel in C# WinForms but haven’t had any success yet.

I have a form (Form1) with a button (button1) and a panel. After the button (button1) is clicked a dialog shows up.

When Dialog.Result from the dialog (Form2) is OK, it should add a chart into the panel with some random value. Multiple charts should be able to be added to the panel.

What I tried so far:
I made a separate class (addGraph) where I wrote a function which creates a column chart with 2 values. Than I tried to call the function in the dialog (Form2) class but this didn’t worked out like expected and showed nothing in the (Form1) panel.

How can I achieve to add charts to the Form1 with function calling in Form2?
Also should I use Panel or GraphControl?

Thanks for your help.

How to transfer valuables between methods? [on hold]

 public partial class Form1 : Form
    public Form1()

    public int answer;

    private void textBox1_TextChanged(object sender, EventArgs e)
        answer = Convert.ToInt32(textBox1.Text);

    private void button1_Click(object sender, EventArgs e)

        label1.Text = Convert.ToString(answer);

How do I make the value of the answer from the first void appear in the second one ?

Visual Studio 17: Facing Test Case not found issue in Visual Studio 17

I am currently working in Visual Studio Professional 2015, and moved to Visual Studio 2017 Enterprise for Code Coverage Testing (because code coverage is available only in Enterprise editions), the problem here is that the test cases which were running fine in VS 2015, are not found by VS 2017. Can’t figure out the issue.

Here is the Log:
No test is available in ProjectPath\bin\Debug\ProjectName.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

enter image description here

Form.Hide does not prevent form from being included in screen dump

The problem

I am using the below code to perform a screen dump. Even though I hide the form itself with this.Hide the form is still being included in the screen dump, which I don’t want it to be.

this.Hide(); //Hide to not include this form in the screen dump

    Rectangle bounds = Screen.GetBounds(Point.Empty);

    using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
        using (Graphics g = Graphics.FromImage(bitmap))
            g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);

        bitmap.Save(fileName, ImageFormat.Png);
catch (Exception exc)
    MessageBox.Show(LanguageMessages.MsgTextErrorScreenDump + 
        Utilities.DoubleNewLine() + exc.ToString(), 
        MessageBoxButtons.OK, MessageBoxIcon.Error);

What I have tried:
Adding the following after hiding the form, which did not make any difference:

  • Sleep(1000);
  • this.Repaint();
  • this.Invalidate();

My question is:
Why does this.Hide not really hide the form, and thus preventing it from being included in the screen dump with the above code?

Displaying Chemical Formulae – WinForms

I’m currently creating a program where chemical formulae are being displayed in a text box. However, the formatting of these formulae is completely wrong and I’m wondering if there’s a better way to do it.

For example, if I was to display the dissociation of H2SO4 in the program, I would have to display it like this:

H2SO4 ? 2H+ + SO42-

Even non-chemists would agree that the formatting is off. For example, the number which shows how many atoms of an element there are should be a subscript, whilst the ion’s charge symbol should be a superscript.

I’m just wondering if there’s a way to display chemical formulae properly. It doesn’t even have to be LaTeX, it could be as simple as displaying sub/superscripts.