Form1.cs
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();
}
DataTable tablo;
private void Form1_Load(object sender, EventArgs e)
{
tablo = new DataTable();
tablo.Columns.Add("Id", typeof(string));
tablo.Columns.Add("UrunAdı", typeof(string));
tablo.Columns.Add("Fiyatı", typeof(string));
tablo.Rows.Add("1", "Apple Laptop", "1500");
tablo.Rows.Add("2", "Casper Laptop", "1500");
tablo.Rows.Add("3", "IBM Laptop", "1500");
tablo.Rows.Add("4", "SATA2 Harddisk", "100");
tablo.Rows.Add("5", "DDR3 Ram", "110");
tablo.Rows.Add("6", "4 GB Flash Bellek", "15");
tablo.Rows.Add("7", "4 GB microSD ", "15");
tablo.Rows.Add("10", "500 GB Pocket Harddisk", "130");
tablo.Rows.Add("11", "19 inc LCD Ekran", "150");
listView1.View = View.Details;
listView1.GridLines = true;
listView1.Columns.Add("Id", 50);
listView1.Columns.Add("Ürün Adı", 100);
listView1.Columns.Add("Fiyatı (USD)", 50);
listView1.SelectedIndexChanged += new EventHandler(listView1_SelectedIndexChanged);
listView1.Items.Clear();
foreach (DataRow row in tablo.Rows)
{
ListViewItem item = new ListViewItem(row["Id"].ToString());
item.SubItems.Add(row["UrunAdı"].ToString());
item.SubItems.Add(row["Fiyatı"].ToString());
listView1.Items.Add(item);
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count > 0)
{
ListViewItem item = listView1.SelectedItems[0];
textBox1.Text = item.SubItems[0].Text;
textBox2.Text = item.SubItems[1].Text;
textBox3.Text = item.SubItems[2].Text;
}
}
}
}
1 comments:
Yav kral adamsın üstad. ellerine sağlık .teşekkürler
Yorum Gönder