c# etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
c# etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

11 Şubat 2014 Salı

C# da Paint Yapımı

c#
c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Paint
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            drawBitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            drawGraphics = Graphics.FromImage(drawBitmap);
            pictureBox1.Image = drawBitmap;
        }
        private Bitmap drawBitmap;
        private Graphics drawGraphics;
        private SolidBrush paintBrush = new SolidBrush(Color.Blue);
        private int paintXSize = 4;
        private int paintYSize = 4;
        private SolidBrush clearBrush = new SolidBrush(Color.White);
        private int clearXSize = 20;
        private int clearYSize = 20;
        private void Form1_Load(object sender, EventArgs e)
        {

        }
        private void cizimYap(int xKoor, int yKoor, MouseEventArgs e)
        {
            drawGraphics.FillRectangle(paintBrush, e.X, e.Y, xKoor, yKoor);
            pictureBox1.Image = drawBitmap;
        }

        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                cizimYap(paintXSize, paintYSize, e);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox2.BackColor = colorDialog1.Color;
                Color renk=new Color();
                renk=colorDialog1.Color;
                paintBrush = new SolidBrush(renk);
            }
        }

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

    }
}



Sitemizin daha kaliteli paylaşımları yapabilmesi için sizin yorumlarınıza ihtiyacımız var :)

10 Şubat 2014 Pazartesi

C# da Çarpım Tablosu Programı

c#
c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

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

private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
double sayi = double.Parse(comboBox1.Text);
for (int i = 1; i < 11; i++)
{
listBox1.Items.Add(sayi + " * " + i + " = " + (sayi * i));
}
}
}
}




Sitemizin daha kaliteli paylaşımları yapabilmesi için sizin yorumlarınıza ihtiyacımız var :)

9 Şubat 2014 Pazar

C# da TextBoxa Tıklanınca TextBox Temizlensin

private void textBox1_Click(object sender, EventArgs e)

{

textBox1.Clear();

}

private void Form1_Load(object sender, EventArgs e)

{

textBox1.Text = "Programlama Hocam";

}


Sitemizin daha kaliteli paylaşımları yapabilmesi için sizin yorumlarınıza ihtiyacımız var :)

24 Ocak 2014 Cuma

C# da Try Catch İle Not Hesaplama

C#
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

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

private void button1_Click(object sender, EventArgs e)
{
int a, b;
double ort;
try
{
a = Convert.ToInt32(textBox1.Text);
b = Convert.ToInt32(textBox2.Text);
if (a<0 || a>100 || b<0 ||b>100)
{
throw new Exception();
}
ort = (a + b) / 2.0;
label4.Text = ort.ToString();
}
catch (Exception)
{
MessageBox.Show("0-100 arası değer giriniz");

}
}
}
}

Sitemizin daha kaliteli paylaşımları yapabilmesi için sizin yorumlarınıza ihtiyacımız var :)

C# da Metod İle Not Hesaplama Ve Geçme Kalma Hesabı

c#
c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

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

private void button1_Click(object sender, EventArgs e)
{
int s1 = Convert.ToInt32(textBox1.Text);
int s2 = Convert.ToInt32(textBox2.Text);
int s3 = Convert.ToInt32(textBox3.Text);
int per = Convert.ToInt32(textBox4.Text);
int temrin = Convert.ToInt32(textBox5.Text);
label6.Text = uygunmu(s1);
label7.Text = uygunmu(s2);
label8.Text = uygunmu(s3);
label9.Text = uygunmu(per);
label10.Text = uygunmu(temrin);
label13.Text = gecerlisayi.ToString();
double ort = gecerliort / (double)gecerlisayi;
label14.Text = ort.ToString();
}
int gecerlisayi , gecerliort ;
string uygunmu(int a)
{
if (a>0 && a<=100)
{
gecerlisayi++;
gecerliort = gecerliort + a;
return "uygun";
}
else
{
return "uygun değil";
}
}
}
}

Sitemizin daha kaliteli paylaşımları yapabilmesi için sizin yorumlarınıza ihtiyacımız var :)

C# da Metod İle Çevre Hesaplama

c#
c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

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

private void button1_Click(object sender, EventArgs e)
{
label1.Text = cevrehesapla(5, 7, 4).ToString();
}
int cevrehesapla(int a, int b, int c)
{
int cevap;
cevap = a + b+c;
return cevap;
}
}
}

Sitemizin daha kaliteli paylaşımları yapabilmesi için sizin yorumlarınıza ihtiyacımız var :)

C# da Diziler İle Talihli Bilet Bulma

c#
c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication12
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int [] talihlibilet = new int [] { 1234567,0987654,5567123,2617213};
int[] sonuc = new int[] { 745, 123, 456, 789, 098, 523, 724, 911 };
int [] amo = new int [] {5,4,7};
private void button1_Click(object sender, EventArgs e)
{
label1.Text = "label2";
int lan = Convert.ToInt32(textBox1.Text);
for (int i = 0; i <= 9; i++)
{
if (lan== talihlibilet[i])
{
label1.Text = "10 milyon kazandınız";
break;
}
if (label2.Text=="label2")
{
for (int ı = 0; ı <=9 ; ı++)
{
int sonucc = lan % 1000;
if (sonucc== sonuc[ı])
{
label2.Text = "1000 tl kazandınız";
break;
}
}
}
}
}
}
}

Sitemizin daha kaliteli paylaşımları yapabilmesi için sizin yorumlarınıza ihtiyacımız var :)

C# da Metod İle Matematik Soru Testi Yapımı

c#
c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication11
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Random r;
int a, b, dcs = 0, sn = 0, ycs = 0, bcs = 0, sure = 10;
private void Form1_Load(object sender, EventArgs e)
{
soru();
timer1.Start();
}
void soru()
{
sn++;
label1.Text = "soru" + sn + ")";
a = r.Next(1, 100);
b = r.Next(1, 100);
label2.Text = a.ToString();
label4.Text = b.ToString();
}

private void button1_Click(object sender, EventArgs e)
{
int c = Convert.ToInt32(textBox1.Text);
if (c==a+b)
{
dcs++;
label9.Text = dcs + "";
}
else
{
ycs++;
label10.Text = ycs + "";
}
soru();
sure = 10;
}

private void timer1_Tick(object sender, EventArgs e)
{
sure--;
if (sure==0)
{
bcs++;
label11.Text = bcs + "";
soru();
sure = 10;
}
label13.Text = sure.ToString();
}
}
}


Sitemizin daha kaliteli paylaşımları yapabilmesi için sizin yorumlarınıza ihtiyacımız var :)

C# da Metod ile Not Hesaplama

c#
c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

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

private void button1_Click(object sender, EventArgs e)
{
int a = Convert.ToInt32(textBox1.Text);
int b = Convert.ToInt32(textBox2.Text);
int c = Convert.ToInt32(textBox3.Text);
int d = Convert.ToInt32(textBox4.Text);
int g = Convert.ToInt32(textBox5.Text);
label6.Text = uygunmu(a);
label7.Text = uygunmu(b);
label8.Text = uygunmu(c);
label9.Text = uygunmu(d);
label10.Text = uygunmu(g);
label14.Text = gs.ToString();
double ort = gns / (double)gs;
label15.Text = gns.ToString();
}
int gs = 0;
int gns = 0;
string uygunmu(int r)
{
if (r>0 && r<=100)
{
gs++;
gns = gns + r;
return "uygun ";
}
else
{
return "uygun değil";
}
}
}
}


Sitemizin daha kaliteli paylaşımları yapabilmesi için sizin yorumlarınıza ihtiyacımız var :)

22 Ocak 2014 Çarşamba

C# da Veri Tabanı Kaydı 2

c#
c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

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

private void karneBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.karneBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.programlamahocamDataSet);

}

private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'programlamahocamDataSet.karne' table. You can move, or remove it, as needed.
this.karneTableAdapter.Fill(this.programlamahocamDataSet.karne);

}
}
}

Sitemizin daha kaliteli paylaşımları yapabilmesi için sizin yorumlarınıza ihtiyacımız var :)

C# da Veri Tabanına Kayıt Ekleme

c#
c#

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

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

private void button1_Click(object sender, EventArgs e)
{
OleDbDataReader data;
DataTable tablo = new DataTable();
// accese veri ekleme komutu
oleDbCommand1.CommandText = "insert into kisi (ad) values (a1)";
oleDbCommand1.Parameters.Add("a1",textBox2.Text);
oleDbCommand1.ExecuteNonQuery();
oleDbCommand1.Parameters.Clear();
// komutun bitişi
//datagridviewe görüntüleme
oleDbCommand1.CommandText = "Select * from kisi";
data = oleDbCommand1.ExecuteReader();
tablo.Load(data);
dataGridView1.DataSource = tablo;
//görüntülemenin sonu
}
private void Form1_Load(object sender, EventArgs e)
{
oleDbConnection1.Open();
}
}
}


Sitemizin daha kaliteli paylaşımları yapabilmesi için sizin yorumlarınıza ihtiyacımız var :)

21 Aralık 2013 Cumartesi

C# da Metod ile Random Kullanma

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

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

private void button1_Click(object sender, EventArgs e)
{
üret();
}
void üret()
{
Random n1 = new Random();
label1.Text = n1.Next(1, 49).ToString();
label2.Text = n1.Next(1, 49).ToString();
label3.Text = n1.Next(1, 49).ToString();
label4.Text = n1.Next(1, 49).ToString();
label5.Text = n1.Next(1, 49).ToString();
label6.Text = n1.Next(1, 49).ToString();


}
}
}


C# da Try Catch ile İş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.Threading.Tasks;
using System.Windows.Forms;

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

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
int s1, s2;
double ort;
try
{
s1 = Convert.ToInt32(textBox1.Text);
s2 = Convert.ToInt32(textBox2.Text);
if ((s1<0 || s1>100)||(s2<0||s2>100))
{
throw new Exception();
}
ort = (s1 + s2) / 2.0;
label4.Text = ort.ToString();
}
catch (Exception)
{

MessageBox.Show("0-100 arası tam sayı giriniz ");
}
}
}
}

C# da Metod ile Ortalama Hesaplama

c#
c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

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

private void button1_Click(object sender, EventArgs e)
{
int a = Convert.ToInt32(textBox1.Text);
int b = Convert.ToInt32(textBox2.Text);
int c = Convert.ToInt32(textBox3.Text);
double x = aritmetikortalama(a, b, c);
double y = geometrikortalama(a, b, c);
double z = harmonikortalama(a, b, c);
int d = 0;
if (checkBox1.Checked==true)
{
listBox1.Items.Add("aritmetikortalama" + x);
d = d + 1;
}
if (checkBox2.Checked==true)
{
listBox1.Items.Add("geometrikortalama" + y);
d = d + 1;
}
if (checkBox3.Checked==true)
{
listBox1.Items.Add("harmonikortalama" + z);
d = d + 1;
}
listBox1.Items.Add(d);
}
double aritmetikortalama(int x1, int x2, int x3)
{
return (x1 + x2 + x3) / 3.0;
}
double geometrikortalama(int x1, int x2, int x3)
{
double go;
int carpım;
carpım = x1 * x2 * x3;
go = Math.Pow(carpım, 1 / 3.0);
return go;
}
double harmonikortalama(int x1, int x2, int x3)
{
return 3.0 / ((1.0 / x1) + (1.0 / x2) + (1.0 / x3));
}

}
}

20 Aralık 2013 Cuma

C# da Kod ile Tablo Oluşturma

c#
c#

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

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

private void button1_Click(object sender, EventArgs e)
{
OleDbConnection VeriTabaniBaglantisi = new OleDbConnection("Provider=Microsoft.Ace.OleDb.12.0;Data Source = ProgramlamaHocam.accdb");

try
{
if (!Convert.ToBoolean(VeriTabaniBaglantisi.State))
{
VeriTabaniBaglantisi.Open();
}
OleDbCommand TabloOlustur = new OleDbCommand("Create Table " + textBox1.Text,
VeriTabaniBaglantisi);

TabloOlustur.ExecuteNonQuery();
MessageBox.Show("İşlem Tamamlandı. " + textBox1.Text + " isimli tabloyu oluşturdunuz...",
"Başarılı");

}
catch (Exception hata)
{
MessageBox.Show(hata.Message.ToString(), "Hata..!", MessageBoxButtons.OK,
MessageBoxIcon.Error);

}
finally
{
if (Convert.ToBoolean(VeriTabaniBaglantisi.State))
{
VeriTabaniBaglantisi.Close();
}
}
}
}
}

C# da Çarpım Tablosu Yapımı

c#
c#

private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();

double sayi = double.Parse(textBox1.Text);

for (int i = 1; i < 11; i++)
{
listBox1.Items.Add(sayi + " * " + i + " = " + (sayi * i));
}

textBox1.Clear();
}

C# da Kod ile Arka Planı Değiştirme

c#
c#

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

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

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

C# da Tuş Okuma

using System;
using System.Runtime.InteropServices;
using System.Threading;
namespace projeadi
{
public static class ReadKey
{
#region events
public static delegate void _GetKey(Keys key,int ascii,bool down);
public static event _GetKey GetKey;
#endregion
#region api
[DllImport("user32.dll")]
public static extern int GetAsyncKeyState(long vKey);
#endregion
#region variables
public static bool[] keys = new down[255];
internal static Thread _readmethods;
internal static bool load=false;
#endregion
#region methods
public static bool Load()
{
if(load)
return false;
load=true;
_readmethods = new Thread(readkeys);
_readmethods.Start();

return true;
}

internal static bool down(int ascii)
{
return (GetAsyncKeyState(ascii) == -32767 || GetAsyncKeyState(ascii) == -32768);
}
internal static void readkeys()
{
while(true)
{
for(int i = 1;i <= 255;i++)
{
#region down
if(down(i))
{
if(!keys[i])
{
keys[i]=true;
if(GetKey!=null)
GetKey((Keys)i,i,keys[i]);
}
}
#endregion
#region up
else
{
if(keys[i])
{
keys[i]=false;
if(GetKey!=null)
GetKey((Keys)i,i,keys[i]);
}
}
#endregion
}
Thread.Sleep(1);
}
}
#endregion
}
}

19 Aralık 2013 Perşembe

C# da Method Uygulaması

c#
c#

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

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

private void button1_Click(object sender, EventArgs e)
{
int a;
a = toplama(2, 15);
label1.Text = a.ToString();
rastgelesayi(5, 15);
}
int toplama (int x , int y )
{
int t = 0;
for (int i = x; i <= y; i++)
{
t = t + i;
}
return t;
}
void rastgelesayi(int a, int b)
{
Random r = new Random();
for (int i = 1; i <= 10; i++)
{
int s;
s = r.Next(a, b);
listBox1.Items.Add(s);
}
}
}
}


C# da Metodlar

c#
c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

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

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
int a = Convert.ToInt32(textBox1.Text);
int b = Convert.ToInt32(textBox2.Text);
int c = Convert.ToInt32(textBox3.Text);
listBox1.Items.Add("çevre"+cevreyaz(a,b,c));
listBox1.Items.Add("alan"+alanyaz(a,b,c));
}
int cevreyaz(int a, int b, int c)
{
return a + b + c;
}
double alanyaz(int a, int b, int c)
{
double u=(a+b+c)/2.0;
double alan=0 , hesap ;
hesap=u*(u-a)*(u-b)*(u-c);
alan=Math.Pow(alan,1/2.0);
return alan ;
}
void ücgenmi(int a, int b, int c)
{
bool k1, k2, k3=
k1=(a<b+c && a>b-c && a>c-b );
k2 = ( b<a+c && b>a-c && b>c-a);
k3 = (c < a + b && c > a - b && c > b - a);
if (k1 == true && k2 == true && k3 == true)
{
listBox1.Items.Add("üçgendir");

}
else
{
listBox1.Items.Add("üçgen değildir " );

}

}
void ücgentürü(int a, int b, int c)
{
if (a==b && b==c && a==c )
{
listBox1.Items.Add("eşkenar üçgen ");

}
else if (a==b || b==c || a==c)
{
listBox1.Items.Add("ikizkenar üçgen");

}
else
{
listBox1.Items.Add("çeşitkenar üçgen");

}
}
}
}