c# – Issue outputting text to textBox (WinForms)

It’s my first time using winforms. I’m having some issues.

   public partial class Form1 : Form
        public Form1()

        private void TextBox1_TextChanged(object sender, EventArgs e)


        private void Form1_Load(object sender, EventArgs e)
            textBox1.Text = "FORM1";
            textBox1.AppendText("SOME TEXT");

I’ve tried this. My textbox is set to fill so it fills up the whole form. I set the multi-line propery to true and dock property to fill.

From what I can try as a first time WinForms user, the Form1_Load should run as soon as the form is created. I’ve tried some various ways to print text, nothing works. I noticed visual studios says “0 references” next to my function. I’m not sure what this means, maybe part of my issue? Please help.

enter image description here

enter image description here

لینک منبع

winforms – Any way to get the width of a Context Menu before it is displayed?

I want to know the what the width of the context menu will be, just before being displayed, possibly in the myContextMenu.popup event handler or better yet, before

The reason I want to know the width, is so that I can affect the location of where it will be painted. Specifically, in the circumstance where the data of a column is right justified, when the operator right clicks, I don’t want the context menu to cover the data, which is typically, also to the right. If I have the width, I can move the context menu to the left by the amount of the width and the top-right corner of the context menu will be at the point of the cursor.

I really do not want to use the myContextMenu.DrawItem event to paint the context menu items unless that is absolutely the only way to accomplish this.

لینک منبع

.net – c# winforms chart – How to get rounded number labels for a scrolling chart

I have a winforms chart which is bound to a List. Every two seconds a new measurement is added to the list. My program is zooming to a 25 second interval and then scrolling to the end of the chart. I would like the x-axis to show multiples of 5 (5, 10, 15, 20…).

chart with rounded labels

In the beginning it works fine, but then when the chart grows bigger and scrolling begins the labels, ticks and gridlines shift (e.g. 23, 28, 33, 38…).

enter image description here

How do I change this so it shows 25, 30, 35, 40… instead?

Here is my code for the chart:

chartArea1.AxisX.LabelStyle.Interval = 5D;
chartArea1.AxisX.MajorGrid.Interval = 5D;
chartArea1.AxisX.MajorTickMark.Interval = 5D;
chartArea1.AxisX.Minimum = 0D;
chartArea1.AxisX.MinorGrid.Interval = 5D;
chartArea1.AxisX.ScaleView.Position = 0D;
chartArea1.AxisX.ScaleView.Size = 25D;
chartArea1.AxisX.ScrollBar.Enabled = false;
chartArea1.AxisX.Title = "Time [s]";
chartArea1.AxisY.Interval = 20D;
chartArea1.AxisY.Title = "Cold pump\nVol. [ml]";
chartArea1.Name = "ChartColdPump";
chartArea1.Position.Auto = false;
chartArea1.Position.Height = 25F;
chartArea1.Position.Width = 99F;

And the code for the scrolling, called each time a new measurement is added to the list:


لینک منبع