1 Ekim 2014 Çarşamba

MenuStrip İle Başka Forma Geçmek


Dosya menüsünün altındaki yeni sekmesine çift tıklanır . Açılan yere göndermek istediğiniz formun adı yazılır.

private void yeniToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form1.ActiveForm.Hide();
            Form2 form2 = new Form2();
            form2.Show();
        }


Kodun Çalıştırılmış Hali


Color Dialog ile Arkaplan Rengini Değiştirme

Aşağıdaki kod butonun içine yazılır .Form içine Dialogs Menüsünden Color Dialog  eklenir .

private void button1_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                this.BackColor = colorDialog1.Color;
            }
        }



Kodun Çalıştırılmış Hali


Metodlarla Dört işlem Yapma

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

    
        public int topla(int s1, int s2)
        {
            int sonuc;
           sonuc = s1 + s2;

           return sonuc;

        }
         public  int cıkar(int s1, int s2)
        {

            return s1 - s2;

        }
         public int carp(int s1, int s2)
        {

            return s1 * s2;

        }
          public int bol(int s1, int s2)
        {

            return s1 /s2;

        }




        private void button3_Click(object sender, EventArgs e)
        {
         textBox3 .Text = carp (Convert.ToInt16(textBox1.Text), Convert.ToInt16(textBox2.Text)).ToString ();
      
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

           textBox3 .Text = topla(Convert.ToInt16(textBox1.Text), Convert.ToInt16(textBox2.Text)).ToString ();
        }

        private void button2_Click(object sender, EventArgs e)
        {
           textBox3 .Text = cıkar(Convert.ToInt16(textBox1.Text), Convert.ToInt16(textBox2.Text)).ToString ();
        }

        private void button4_Click(object sender, EventArgs e)
        {
              textBox3 .Text =bol (Convert.ToInt16(textBox1.Text), Convert.ToInt16(textBox2.Text)).ToString ();
    }
        }
        }

Kodun Çalıştırılmış Hali