На главную Наши проекты:
Журнал   ·   Discuz!ML   ·   Wiki   ·   DRKB   ·   Помощь проекту
ПРАВИЛА FAQ Помощь Участники Календарь Избранное RSS
Дорогие друзья! Поздравляем вас с днём Победы!
msm.ru
  
> First step ... , Помогите сделать 1 шаг C#
    Помогите сделать 1 шаг к C#

    Не сочтите за наглость, просьбу:

    Сделайте на C# проект с 1 окошком.

    На нем 3 поля : Первое слагаемое, второе, сумма.
    Кнопарь "Сложить"

    Хочется посмотреть как это делается.

    Заранее спасибо.
      wink.gif
      Вот пожалуйста:

      using System;
      using System.Drawing;
      using System.Collections;
      using System.ComponentModel;
      using System.Windows.Forms;
      using System.Data;

      namespace WindowsApplication3
      {
      /// <summary>
      /// Summary description for Form1.
      /// </summary>
      public class Form1 : System.Windows.Forms.Form
      {
      private System.Windows.Forms.TextBox textSlog1;
      private System.Windows.Forms.TextBox textSlog2;
      private System.Windows.Forms.TextBox textResult;
      private System.Windows.Forms.Button btSetResult;
      private System.Windows.Forms.Label label1;
      /// <summary>
      /// Required designer variable.
      /// </summary>
      private System.ComponentModel.Container components = null;

      public Form1()
      {
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();

      //
      // TODO: Add any constructor code after InitializeComponent call
      //
      }

      /// <summary>
      /// Clean up any resources being used.
      /// </summary>
      protected override void Dispose( bool disposing )
      {
      if( disposing )
      {
      if (components != null)
      {
      components.Dispose();
      }
      }
      base.Dispose( disposing );
      }

      #region Windows Form Designer generated code
      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      private void InitializeComponent()
      {
      this.textSlog1 = new System.Windows.Forms.TextBox();
      this.textSlog2 = new System.Windows.Forms.TextBox();
      this.textResult = new System.Windows.Forms.TextBox();
      this.btSetResult = new System.Windows.Forms.Button();
      this.label1 = new System.Windows.Forms.Label();
      this.SuspendLayout();
      //
      // textSlog1
      //
      this.textSlog1.Location = new System.Drawing.Point(8, 8);
      this.textSlog1.Name = "textSlog1";
      this.textSlog1.TabIndex = 0;
      this.textSlog1.Text = "";
      //
      // textSlog2
      //
      this.textSlog2.Location = new System.Drawing.Point(144, 8);
      this.textSlog2.Name = "textSlog2";
      this.textSlog2.TabIndex = 1;
      this.textSlog2.Text = "";
      //
      // textResult
      //
      this.textResult.Location = new System.Drawing.Point(304, 8);
      this.textResult.Name = "textResult";
      this.textResult.TabIndex = 2;
      this.textResult.Text = "";
      //
      // btSetResult
      //
      this.btSetResult.Location = new System.Drawing.Point(256, 8);
      this.btSetResult.Name = "btSetResult";
      this.btSetResult.Size = new System.Drawing.Size(32, 23);
      this.btSetResult.TabIndex = 3;
      this.btSetResult.Text = "=";
      this.btSetResult.Click += new System.EventHandler(this.btSetResult_Click);
      //
      // label1
      //
      this.label1.Location = new System.Drawing.Point(120, 10);
      this.label1.Name = "label1";
      this.label1.Size = new System.Drawing.Size(16, 16);
      this.label1.TabIndex = 4;
      this.label1.Text = "+";
      //
      // Form1
      //
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(560, 149);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {
      this.label1,
      this.btSetResult,
      this.textResult,
      this.textSlog2,
      this.textSlog1});
      this.Name = "Form1";
      this.Text = "Form1";
      this.ResumeLayout(false);

      }
      #endregion

      /// <summary>
      /// The main entry point for the application.
      /// </summary>
      [STAThread]
      static void Main()
      {
      Application.Run(new Form1());
      }

      private void btSetResult_Click(object sender, System.EventArgs e)
      {
      if(textSlog1.Text != "" && textSlog2.Text != "")
      {
      textResult.Text = ((int)(Convert.ToInt32(textSlog1.Text, 10) +
      Convert.ToInt32(textSlog2.Text, 10))).ToString();
      }
      }
      }
      }
        biggrin.gif не пугайся около 90% этого кода было сгенерено автоматически ph34r.gif
          100 спасибов hFoxy, как говорила моя бабушка.

            biggrin.gif незачто
            1 пользователей читают эту тему (1 гостей и 0 скрытых пользователей)
            0 пользователей:


            Рейтинг@Mail.ru
            [ Script execution time: 0,0262 ]   [ 15 queries used ]   [ Generated: 12.05.24, 15:29 GMT ]