добавили выбор с клавиатуры
This commit is contained in:
parent
cd24abb4ea
commit
0c446bbcfb
|
|
@ -490,6 +490,7 @@
|
|||
this.tb_comp.MouseClick += new System.Windows.Forms.MouseEventHandler(this.tb_comp_MouseClick);
|
||||
this.tb_comp.TextChanged += new System.EventHandler(this.cb_comp_TextUpdate);
|
||||
this.tb_comp.Enter += new System.EventHandler(this.tb_comp_Enter);
|
||||
this.tb_comp.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tb_comp_KeyDown);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ namespace Reseter2
|
|||
public event updateSetting UpdateSetting;
|
||||
private ListBox ListComp;
|
||||
private IComp CompSelected = null;
|
||||
private int PreSelected = -1;
|
||||
public Form1()
|
||||
{
|
||||
|
||||
|
|
@ -60,7 +61,9 @@ namespace Reseter2
|
|||
ListComp = new ListBox();
|
||||
this.Controls.Add(ListComp);
|
||||
ListComp.GotFocus += tb_comp_Enter;
|
||||
|
||||
ListComp.DrawMode = DrawMode.OwnerDrawFixed;
|
||||
ListComp.DrawItem += ListComp_DrawItem;
|
||||
//ListComp.SetSelected(1,true);
|
||||
|
||||
InitializeComponent();
|
||||
this.Save += settingWordsControl1.Save;
|
||||
|
|
@ -543,6 +546,7 @@ namespace Reseter2
|
|||
|
||||
private void cb_comp_TextUpdate(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Cursor.Current = Cursors.Default;
|
||||
if (sender is TextBox)
|
||||
{
|
||||
|
|
@ -554,12 +558,14 @@ namespace Reseter2
|
|||
}
|
||||
public void cb_comp_ResultUpdate(List<string> Items, bool enable)
|
||||
{
|
||||
PreSelected = -1;
|
||||
if (ListComp.Items.Count != Items.Count) ListComp.Height = ListComp.ItemHeight * (Items.Count+1) ;
|
||||
ListComp.Items.Clear();
|
||||
ListComp.Items.AddRange(Items.ToArray());
|
||||
ListComp.Enabled = enable;
|
||||
// ListComp.Visible = true;
|
||||
|
||||
|
||||
// ListComp.Visible = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -581,6 +587,24 @@ namespace Reseter2
|
|||
|
||||
}
|
||||
|
||||
|
||||
private void ListComp_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
if(e.Index != -1) {
|
||||
if(e.Index == PreSelected)
|
||||
{
|
||||
e.Graphics.FillRectangle(Brushes.LightGray, e.Bounds);
|
||||
}
|
||||
|
||||
if(e.Index == ListComp.SelectedIndex)
|
||||
{
|
||||
e.Graphics.FillRectangle(Brushes.LightBlue, e.Bounds);
|
||||
}
|
||||
e.Graphics.DrawString(ListComp.Items[e.Index].ToString(), e.Font, Brushes.Black, e.Bounds.Location);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if ((m.Msg == 0x210 && m.WParam.ToInt32() == 513) || m.Msg == 0x201)
|
||||
|
|
@ -595,6 +619,36 @@ namespace Reseter2
|
|||
}
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
private void tb_comp_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
Console.WriteLine(e.KeyValue.ToString());
|
||||
switch (e.KeyValue)
|
||||
{
|
||||
case 40:
|
||||
if(PreSelected < ListComp.Items.Count-1) ++PreSelected;
|
||||
e.SuppressKeyPress = true;
|
||||
ListComp.Refresh();
|
||||
break;
|
||||
case 38:
|
||||
if (PreSelected > 0) --PreSelected;
|
||||
e.SuppressKeyPress = true;
|
||||
ListComp.Refresh();
|
||||
break;
|
||||
case 13:
|
||||
if (PreSelected >= 0)
|
||||
{
|
||||
ListComp.SelectedIndex = PreSelected;
|
||||
e.SuppressKeyPress = true;
|
||||
ListComp.Refresh();
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@
|
|||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0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EAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
|
||||
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
|
||||
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
|
||||
|
|
|
|||
|
|
@ -49,22 +49,25 @@ namespace Reseter2.Seacher
|
|||
}
|
||||
public List<string> ResultSeach(string seach)
|
||||
{
|
||||
|
||||
string sql = "SELECT * FROM " + SGlobalSetting.settingSCCM.dataBase + " WHERE pcname LIKE " + seach;
|
||||
MySqlCommand sqlCom = new MySqlCommand(sql, Connection);
|
||||
// Connection.Open();
|
||||
sqlCom.ExecuteNonQuery();
|
||||
MySqlDataAdapter dataAdapter = new MySqlDataAdapter(sqlCom);
|
||||
DataTable dt = new DataTable();
|
||||
dataAdapter.Fill(dt);
|
||||
if(Connection != null)
|
||||
{
|
||||
string sql = "SELECT * FROM " + SGlobalSetting.settingSCCM.dataBase + " WHERE pcname LIKE " + seach;
|
||||
MySqlCommand sqlCom = new MySqlCommand(sql, Connection);
|
||||
// Connection.Open();
|
||||
sqlCom.ExecuteNonQuery();
|
||||
MySqlDataAdapter dataAdapter = new MySqlDataAdapter(sqlCom);
|
||||
DataTable dt = new DataTable();
|
||||
dataAdapter.Fill(dt);
|
||||
|
||||
var myData = dt.Select();
|
||||
//for (int i = 0; i < myData.Length; i++)
|
||||
//{
|
||||
// for (int j = 0; j < myData[i].ItemArray.Length; j++)
|
||||
// richTextBox1.Text += myData[i].ItemArray[j] + " ";
|
||||
// richTextBox1.Text += "\n";
|
||||
//}
|
||||
}
|
||||
|
||||
var myData = dt.Select();
|
||||
//for (int i = 0; i < myData.Length; i++)
|
||||
//{
|
||||
// for (int j = 0; j < myData[i].ItemArray.Length; j++)
|
||||
// richTextBox1.Text += myData[i].ItemArray[j] + " ";
|
||||
// richTextBox1.Text += "\n";
|
||||
//}
|
||||
return null;
|
||||
}
|
||||
public void Activate()
|
||||
|
|
@ -76,6 +79,7 @@ namespace Reseter2.Seacher
|
|||
{
|
||||
Connection = new MySql.Data.MySqlClient.MySqlConnection(stringConnect);
|
||||
Connection.Open();
|
||||
Console.WriteLine("Подключились");
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue