Click here to Skip to main content
15,911,139 members
Home / Discussions / C#
   

C#

 
AnswerRe: ListView Pin
Henry Minute6-May-09 13:37
Henry Minute6-May-09 13:37 
AnswerRe: ListView Pin
Roberto Ho6-May-09 13:50
Roberto Ho6-May-09 13:50 
AnswerRe: ListView Pin
nsimbu6-May-09 13:51
nsimbu6-May-09 13:51 
QuestionConvert .Net datatype to Mysql datatype Pin
student19886-May-09 12:14
student19886-May-09 12:14 
AnswerRe: Convert .Net datatype to Mysql datatype Pin
Colin Angus Mackay6-May-09 12:21
Colin Angus Mackay6-May-09 12:21 
GeneralRe: Convert .Net datatype to Mysql datatype Pin
student19886-May-09 12:37
student19886-May-09 12:37 
GeneralRe: Convert .Net datatype to Mysql datatype Pin
Colin Angus Mackay6-May-09 12:47
Colin Angus Mackay6-May-09 12:47 
GeneralRe: Convert .Net datatype to Mysql datatype Pin
student19886-May-09 13:01
student19886-May-09 13:01 
GeneralRe: Convert .Net datatype to Mysql datatype Pin
Luc Pattyn6-May-09 13:09
sitebuilderLuc Pattyn6-May-09 13:09 
GeneralRe: Convert .Net datatype to Mysql datatype Pin
student19886-May-09 13:26
student19886-May-09 13:26 
GeneralRe: Convert .Net datatype to Mysql datatype Pin
Luc Pattyn6-May-09 13:58
sitebuilderLuc Pattyn6-May-09 13:58 
QuestionGateway port forwarding Pin
evangile6-May-09 11:47
evangile6-May-09 11:47 
AnswerRe: Gateway port forwarding Pin
harold aptroot6-May-09 11:59
harold aptroot6-May-09 11:59 
GeneralRe: Gateway port forwarding Pin
evangile6-May-09 12:05
evangile6-May-09 12:05 
QuestionRe: Gateway port forwarding Pin
harold aptroot6-May-09 12:10
harold aptroot6-May-09 12:10 
AnswerRe: Gateway port forwarding Pin
evangile6-May-09 12:17
evangile6-May-09 12:17 
GeneralRe: Gateway port forwarding Pin
harold aptroot6-May-09 22:08
harold aptroot6-May-09 22:08 
GeneralRe: Gateway port forwarding Pin
evangile6-May-09 23:05
evangile6-May-09 23:05 
GeneralRe: Gateway port forwarding Pin
harold aptroot6-May-09 23:36
harold aptroot6-May-09 23:36 
QuestionFind out if a class is initialized with reflection. Pin
belzer6-May-09 11:26
belzer6-May-09 11:26 
QuestionProcess.Kill() problem Pin
Mel Feik6-May-09 10:42
Mel Feik6-May-09 10:42 
GeneralI made a T9 Dictianary [modified] Pin
emrah19826-May-09 10:26
emrah19826-May-09 10:26 
I made a T9 dictionary please take look I'am waiting your opinions.

Here is the code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace T9Sozluk
{
    public partial class frmT9 : Form
    {
        public frmT9()
        {
            InitializeComponent();
        }

        SqlConnection Baglanti = new SqlConnection(Properties.Settings.Default.DBYolu.ToString());
        SqlCommand Komut;
        SqlDataReader dr;
        string text = "", sonuc = "";
        string[] dizi = new string[1];
        int sayi = 0, deger=0, Lstart = 0, Lend = 0;
        Point pnt;
        bool swich = true;
        bool show = true;

        private void Form1_Load(object sender, EventArgs e)
        {
            Baglan(true);
            listBox1.Hide();
        }

        public void Baglan(bool value)
        {
            if (value)
            {
                if (Baglanti.State == ConnectionState.Closed)
                    Baglanti.Open();       
            }
            else if (!value)
            {
                if (Baglanti.State == ConnectionState.Open)
                    Baglanti.Close();       
            }
        }

        private void MakeSelection()
        {
            richTextBox1.SelectionStart = richTextBox1.TextLength;
            richTextBox1.SelectedText = Convert.ToString(listBox1.SelectedItem);
            sonuc = richTextBox1.Text;
            sonuc = sonuc.Remove((Lend - sayi), sayi);
            richTextBox1.Text = sonuc;
            Lstart = richTextBox1.TextLength;
            swich = true;
            listBox1.Hide();
            //richTextBox1.Cursor = 
        }

        private void ShowSelection()
        {
            if (!show)
            {
                
                listBox1.Items.Clear();

                Lend = richTextBox1.TextLength;
                sayi = Lend - Lstart;
                text = richTextBox1.Text;
                if (Lstart > 3)
                    text = text.Remove(0,Lend-sayi);

                text = text.TrimStart(Convert.ToChar(" "));
                sayi = text.Length;
                text = text + "%";

                Komut = new SqlCommand("select count(kelimeadi) from kelimeler where " +
                                           "kelimeadi like @KelimeAdi", Baglanti);
                Komut.Parameters.Add("@KelimeAdi", SqlDbType.NVarChar).Value = text.ToString();


                try
                {
                    dr = Komut.ExecuteReader(CommandBehavior.SingleResult);
                    if (dr.Read())
                        deger = dr.GetInt32(0);
                }
                catch (Exception hata)
                {
                    MessageBox.Show(hata.ToString());
                }
                dr.Close();
                dr.Dispose();

                if (deger>0)
                {
                    Komut = new SqlCommand("Select Kelimeadi From Kelimeler Where" +
                                           " KelimeAdi like @KelimeAdi", Baglanti);
                    Komut.Parameters.Add("@KelimeAdi", SqlDbType.NVarChar).Value = text;
                    dr = Komut.ExecuteReader();

                    if (dr.Read())
                    {
                        for (int i = 0; i < deger; i++)
                        {
                            dizi[0] = dr.GetString(0);
                            listBox1.Items.Add(dizi[0]);
                            dr.Read();
                        }
                    }
                    dr.Close();
                    dr.Dispose();
                }

                if (deger>0)
                {
                    pnt = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength);
                    pnt.X = pnt.X + 15;
                    pnt.Y = pnt.Y + 20;
                    listBox1.Location = pnt;
                    listBox1.Show();
                }
            }
        }

        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar == 17))
            {
                show = false;
                swich = false;
            }
            else
                show = true;

            if (!swich)
            {
                if (e.KeyChar == 13)
                    MakeSelection();
                else
                    ShowSelection();
            }
        }

        private void tsItemEkle_Click(object sender, EventArgs e)
        {
            Komut = new SqlCommand("Insert into Kelimeler(KelimeAdi) values(@KelimeAdi)", Baglanti);
            Komut.Parameters.Add("@KelimeAdi", SqlDbType.NVarChar).Value = text.Remove(sayi);

            try
            {
                Komut.ExecuteNonQuery();
                MessageBox.Show("Kelime Listeye Eklendi...");
            }
            catch (Exception hata)
            {
                MessageBox.Show(Convert.ToString(hata));
            }
            return;
        }
    }
}


modified on Wednesday, May 6, 2009 4:46 PM

GeneralRe: I made a T9 Dictianary Pin
Henry Minute6-May-09 10:32
Henry Minute6-May-09 10:32 
GeneralRe: I made a T9 Dictianary Pin
emrah19826-May-09 10:48
emrah19826-May-09 10:48 
GeneralRe: I made a T9 Dictianary Pin
led mike6-May-09 10:36
led mike6-May-09 10:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.