Bu başlık altında yaptığım tüm örneklerin uygulamalarını ara ara yayınlıyorum , ve yayınlamaya devam edeceğim.Herşey sizler için, takibe devam :)
8 Temmuz 2014 Salı
12 Temmuz 2013 Cuma
Çarpışan İki Topun Yönlerini Değiştirmesi
Çalışma sayfamıza iki tane timer ekliyoruz. Sol taraftaki
topun adı top1 , sağ taraftaki topu adı ise
top2 dir.
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 Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void
button2_Click(object sender, EventArgs e)
{
Form1 f2 = new Form1();
f2.Show();
this.Hide();
}
private void
Form3_Load(object sender, EventArgs e)
{
timer1.Stop();
timer2.Stop();
}
private void
button1_Click(object sender, EventArgs e)
{
timer1.Start();
timer2.Start();
}
private void
timer1_Tick(object sender, EventArgs e)
{
top1.Left = top1.Left + 10;
top2.Left = top2.Left - 10;
if (top1.Right > top2.Left) timer1.Stop();
}
private void
timer2_Tick(object sender, EventArgs e)
{
if (top1.Right > top2.Left) top1.Top = top1.Top +
10;
if (top1.Right > top2.Left) top2.Top = top2.Top -
10;
}
}
}
5 Mayıs 2013 Pazar
Listbox a Girilen Aynı Değeri Eklememe
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();
}
string[] meyvalar = new
string[100];
int i = 0;
int meyvavar = 0;// bayrak
görevini görür.
private void
button1_Click(object sender, EventArgs e)
{
for (int sayaç = 0; sayaç < i; sayaç++)
{
if (meyvalar[sayaç] == textBox1.Text)
{
MessageBox.Show("bu meyva daha önce eklendi");
textBox1.Text = "";
meyvavar = 1;// daha önce meyve girilmiştir anlamına
geliyor.
}
}
if (meyvavar == 0) // daha önce
aynı meyve girilmemişse eğer anlamına geliyor.
{
listBox1.Items.Add(textBox1.Text);
meyvalar[i] = textBox1.Text;
textBox1.Text="";
}
meyvavar=0;
i++;
}
}
}

4 Nisan 2013 Perşembe
C# Kodlarıyla Veritabanına Resim Ekleme
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;
using System.Data.OleDb;
namespace resim_ekleme
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection bağlantı;
OleDbCommand sqlkomutu;
OleDbDataAdapter da;
DataSet ds;
private void güncelle()
{
da = new OleDbDataAdapter("Select * from tablo", bağlantı);
ds = new DataSet();
bağlantı.Open();
da.Fill(ds, "tablo");
bağlantı.Close();
dataGridView1.DataSource = ds.Tables["tablo"];
}
private void
Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the
'listeDataSet1.tablo' table. You can move, or remove it, as needed.
this.tabloTableAdapter1.Fill(this.listeDataSet1.tablo);
bağlantı = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=liste.mdb");
güncelle();
}
private void
button1_Click(object sender, EventArgs e) // Aç butonuna yazılır
{
pictureBox1.Visible = true;
openFileDialog1.ShowDialog();
pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
}
int seçilensatır;
private void
button2_Click(object sender, EventArgs e) //Kaydet butonuna yazılır
{
try
{
string foto = openFileDialog1.FileName;
// bağlantı
= new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=liste.mdb");
sqlkomutu = new OleDbCommand(
"update tablo set foto=@foto where
Kimlik=" + seçilensatır, bağlantı);
bağlantı.Open();
sqlkomutu.Parameters.Add("@foto",
OleDbType.Char, 250).Value = foto;
sqlkomutu.ExecuteNonQuery();
bağlantı.Close();
güncelle();
}
catch
{
}
}
private void
dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
try
{
seçilensatır = Convert.ToInt16(ds.Tables["tablo"].Rows[e.RowIndex]["Kimlik"]);
if (ds.Tables["tablo"].Rows[e.RowIndex]["foto"].ToString() == "")
pictureBox1.Visible = false;
else
{
pictureBox1.Visible = true;
pictureBox1.Image = Image.FromFile(
ds.Tables["tablo"].Rows[e.RowIndex]["foto"].ToString());
}
}
catch { }
}
}
}
Veri tabanından Arama 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;
using System.Data.OleDb;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection bağlantı;
OleDbCommand sqlkomutu;
OleDbDataAdapter da;
DataSet ds;
private void güncelle()
{
da = new OleDbDataAdapter("Select * from tablo", bağlantı);
ds = new DataSet();
bağlantı.Open();
da.Fill(ds, "tablo");
bağlantı.Close();
dataGridView1.DataSource = ds.Tables["tablo"];
}
private void
Form1_Load(object sender, EventArgs e)
{
bağlantı = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=liste.mdb");
güncelle();
// TODO: This line of code loads data into the
'listeDataSet1.tablo' table. You can move, or remove it, as needed.
this.tabloTableAdapter.Fill(this.listeDataSet1.tablo);
}
private void
button1_Click(object sender, EventArgs e) // Ara butonuna yazılır
{ da
= new OleDbDataAdapter(
"Select * from tablo where adı Like
'" + textBox1.Text + "%'",
bağlantı);// ½ işareti texbox sa girilen karakterden
sonra sonuna hangi harf gelirse gelsin tümünü göster demektir.
ds = new DataSet();
bağlantı.Open();
da.Fill(ds, "tablo");
bağlantı.Close();
dataGridView1.DataSource = ds.Tables["tablo"];
}
}
}
2 Nisan 2013 Salı
DataGridViewden Ve Veritabanından Veri Silme
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;
using System.Data.OleDb;
namespace DataGridViewden_ve____veritabanından_veri_silme
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection bağlantı;
OleDbCommand sqlkomutu;
OleDbDataAdapter
da;
DataSet ds;
private void güncelle()
{
da = new OleDbDataAdapter("Select * from tablo", bağlantı);
ds = new DataSet();
bağlantı.Open();
da.Fill(ds, "tablo");
bağlantı.Close();
dataGridView1.DataSource = ds.Tables["tablo"];
}
private void
Form1_Load(object sender, EventArgs e)
{
bağlantı = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=liste.mdb");
güncelle();
// TODO: This line of code loads data into the
'listeDataSet.tablo' table. You can move, or remove it, as needed.
this.tabloTableAdapter.Fill(this.listeDataSet.tablo);
}
int seçilensatır;
private void
button2_Click(object sender, EventArgs e) //Öğrenci sil butonuna yazılır
{
sqlkomutu = new OleDbCommand("delete from tablo where Kimlik=" + seçilensatır,
bağlantı);
bağlantı.Open();
sqlkomutu.ExecuteNonQuery();
bağlantı.Close();
güncelle();
}
private void
dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
seçilensatır = Convert.ToInt16(ds.Tables["tablo"].Rows[e.RowIndex]["Kimlik"]);
}
}
}
1 Nisan 2013 Pazartesi
DataGridView de ve Veritabanında Veri Ekleme
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;
using System.Data.OleDb;
namespace DataGridView_e_ve_veritabanına_veri_ekleme
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection bağlantı;
OleDbCommand sqlkomutu;
OleDbDataAdapter da;
DataSet ds;
private void güncelle()
{
da = new OleDbDataAdapter("Select * from tablo", bağlantı);
ds = new DataSet();
bağlantı.Open();
da.Fill(ds, "tablo");
bağlantı.Close();
dataGridView1.DataSource = ds.Tables["tablo"];
}
private void
Form1_Load(object sender, EventArgs e)
{
bağlantı = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=liste.mdb");
güncelle();
// TODO: This line of code loads data into the
'listeDataSet.tablo' table. You can move, or remove it, as needed.
this.tabloTableAdapter.Fill(this.listeDataSet.tablo);
}
private void
button2_Click(object sender, EventArgs e) // Öğrenci ekle butonuna yazılır
{
string numara = textBox2.Text;
string adı = textBox3.Text;
string soyadı = textBox4.Text;
string vize = textBox5.Text;
string final = textBox6.Text;
sqlkomutu = new OleDbCommand(
"insert into tablo(numara,adı,soyadı,vize,final)
Values(@numara,@adı,@soyadı,@vize,@final)", bağlantı);
bağlantı.Open();
sqlkomutu.Parameters.Add("@numara",
OleDbType.Char, 50).Value = numara;
sqlkomutu.Parameters.Add("@adı",
OleDbType.Char, 50).Value = adı;
sqlkomutu.Parameters.Add("@soyadı",
OleDbType.Char, 50).Value = soyadı;
sqlkomutu.Parameters.Add("@vize",
OleDbType.Char, 3).Value = vize;
sqlkomutu.Parameters.Add("@final",
OleDbType.Char, 3).Value = final;
sqlkomutu.ExecuteNonQuery();
bağlantı.Close();
güncelle();
}
}
}
Kaydol:
Kayıtlar (Atom)




