Untitled
unknown
plain_text
a year ago
2.4 kB
19
Indexable
using System;
using System.IO;
using System.Windows.Forms;
namespace WindowsFormsApp29
{
public partial class Form1 : Form
{
String Data;
public Form1()
{
InitializeComponent();
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
string[] veriler = (string[])e.Data.GetData(DataFormats.FileDrop, false);
StreamReader reader = new StreamReader(veriler[0]);
Data = reader.ReadToEnd();
}
private void Form1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
e.Effect = DragDropEffects.None;
}
private void Form1_Load(object sender, EventArgs e)
{
Data = null;
lst_cities.Items.Add("İstanbul");
lst_cities.Items.Add("Kocaeli");
lst_cities.Items.Add("Artvin");
lst_cities.SelectionMode = SelectionMode.MultiExtended;
}
private void btn_search_Click(object sender, EventArgs e)
{
string key = tb_search.Text;
MessageBox.Show("Aranan : '" + key + "' " +(Data.Contains(key) ? "Mevcut!" : "Mevcut değil!"));
}
private void btn_rakamsayisi_Click(object sender, EventArgs e)
{
String num = tb_rakam.Text;
int digit = Convert.ToInt32(num);
int count = 0;
if (digit > 10 || digit < 0)
{
MessageBox.Show("Lütfen rakam giriniz");
return;
}
count = 0;
char digitChar = (char)('0' + digit);
foreach (char c in Data)
if (c == digitChar)
count++;
MessageBox.Show("Aranan Rakam: '" + digit + "' " + count + " kadar bulunuyor!");
}
private void btn_fetch_Click(object sender, EventArgs e)
{
for (int i = 0; i < lst_cities.Items.Count; i++)
{
var item = lst_cities.Items[i];
if (Data.Contains(item.ToString()))
lst_cities.SetSelected(i, true);
}
}
}
}Editor is loading...
Leave a Comment