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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 12; i++)
{
dataGridView1.Rows.Add();
}
for (int i = 0; i < 3; i++)
{
dataGridView1[0, i].Value = "Ahmet";
}
for (int i = 3; i < 7; i++)
{
dataGridView1[0, i].Value = "Mehmet";
}
for (int i = 7; i < 12; i++)
{
dataGridView1[0, i].Value = "mustafa";
}
}
Dictionary < string, int > tekrarlayanSayisi = new Dictionary < string, int > ();
private void buttonSınıflandır_Click(object sender, EventArgs e)
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (tekrarlayanSayisi.ContainsKey(dataGridView1[0, i].Value.ToString()))
{
tekrarlayanSayisi[dataGridView1[0, i].Value.ToString()] =
int.Parse(tekrarlayanSayisi[dataGridView1[0, i].Value.ToString()].ToString()) + 1;
}
else
{
tekrarlayanSayisi.Add(dataGridView1[0,i].Value.ToString(), 1);
}
}
int satir = 0;
dataGridView2.Rows.Clear();
foreach (KeyValuePair < string, int > item in tekrarlayanSayisi )
{
dataGridView2.Rows.Add();
dataGridView2[0, satir].Value = item.Key;
dataGridView2[1, satir].Value = item.Value;
satir++;
}
}
}
}
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 12; i++)
{
dataGridView1.Rows.Add();
}
for (int i = 0; i < 3; i++)
{
dataGridView1[0, i].Value = "Ahmet";
}
for (int i = 3; i < 7; i++)
{
dataGridView1[0, i].Value = "Mehmet";
}
for (int i = 7; i < 12; i++)
{
dataGridView1[0, i].Value = "mustafa";
}
}
Dictionary < string, int > tekrarlayanSayisi = new Dictionary < string, int > ();
private void buttonSınıflandır_Click(object sender, EventArgs e)
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (tekrarlayanSayisi.ContainsKey(dataGridView1[0, i].Value.ToString()))
{
tekrarlayanSayisi[dataGridView1[0, i].Value.ToString()] =
int.Parse(tekrarlayanSayisi[dataGridView1[0, i].Value.ToString()].ToString()) + 1;
}
else
{
tekrarlayanSayisi.Add(dataGridView1[0,i].Value.ToString(), 1);
}
}
int satir = 0;
dataGridView2.Rows.Clear();
foreach (KeyValuePair < string, int > item in tekrarlayanSayisi )
{
dataGridView2.Rows.Add();
dataGridView2[0, satir].Value = item.Key;
dataGridView2[1, satir].Value = item.Value;
satir++;
}
}
}
}
Hiç yorum yok :
Yorum Gönder