Hi, can some kind soul advise me on my coding cos it does not seem to work.

private void DisplayText(object sender, EventArgs e)
          {
              textBox1.Display();

              if (10<x && x<294) && (-5<y && y<13) && (-12<z && z< 228))
                  textBox1.display("It has moved inwards");

              else if (-53<x<-265 && -11<y<37 && -57<z<218)
                  textBox1.display("It has moved outwards");

              else if (10<x<23 && -7<y<280 && -20<z<296)
                  textBox1.displaytext("It has moved right side");

              else if (-7<x<26 && -256<y<0 && -67<z<230)
                  textBox1.display("It has moved left side");
              else
                  MessageBox.Show("Pls try again.");
          }

It cant compile and the problems are: Lines in red have error compiling.. Someone pls help me.

Error 1 'System.Windows.Forms.TextBox' does not contain a definition for 'Display' and no extension method 'Display' accepting a first argument of type 'System.Windows.Forms.TextBox' could be found (are you missing a using directive or an assembly reference?) C:\Users\Jean\Documents\Visual Studio 2008\Projects\SimpleSerial\SimpleSerial\Form1.cs

It states that the class TextBox does not have a method named Display(). In the MSDN they have an example for using C# text boxes:

private void CreateMyMultilineTextBox()
 {
    // Create an instance of a TextBox control.
    TextBox textBox1 = new TextBox();
    
    // Set the Multiline property to true.
    textBox1.Multiline = true;
    // Add vertical scroll bars to the TextBox control.
    textBox1.ScrollBars = ScrollBars.Vertical;
    // Allow the RETURN key to be entered in the TextBox control.
    textBox1.AcceptsReturn = true;
    // Allow the TAB key to be entered in the TextBox control.
    textBox1.AcceptsTab = true;
    // Set WordWrap to True to allow text to wrap to the next line.
    textBox1.WordWrap = true;
    // Set the default text of the control.
    textBox1.Text = "Welcome!";
 }

Take a look at the last line:

textBox1.Text = "Welcome!";

Perhaps this is what you need?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.