fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using MetroFramework.Controls;
  11. using Battery_Tracker.Models;
  12. using Battery_Tracker.DAL;
  13. using MetroFramework;
  14.  
  15. namespace Battery_Tracker.Controls
  16. {
  17. public partial class uclSearch : MetroUserControl
  18. {
  19. SqlDBContext sdb = new SqlDBContext();
  20. public uclSearch()
  21. {
  22. InitializeComponent();
  23. int limit = 5;
  24. DataTable dtUser = new DataTable();
  25. dtUser.Columns.AddRange(new DataColumn[] { new DataColumn("Key"), new DataColumn("Name") });
  26. var data = sdb.Users.ToList();//.Where(a => a.UserName.Contains(name)).Take(limit).ToList();
  27. foreach (var row in data)
  28. {
  29. dtUser.Rows.Add(row.UserId, row.UserName);
  30. }
  31.  
  32. //comboBox1.Text = name;
  33. //comboBox1.DataSource = null;
  34. comboBox1.DataSource = dtUser;
  35. comboBox1.DisplayMember = "Name";
  36. comboBox1.ValueMember = "Key";
  37. //comboBox1.DroppedDown = true;
  38. comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
  39. comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;
  40. comboBox1.DropDownStyle = ComboBoxStyle.DropDown;
  41. }
  42.  
  43. private void comboBox2_KeyPress(object sender, KeyPressEventArgs e)
  44. {
  45. int limit = 5;
  46. DataTable dtUser = new DataTable();
  47. dtUser.Columns.AddRange(new DataColumn[] { new DataColumn("Key"), new DataColumn("Name") });
  48. //var name = comboBox1.Text;
  49. string name = string.Format("{0}{1}", comboBox2.Text, e.KeyChar.ToString());
  50. var data = sdb.Users.Where(a => a.UserName.Contains(name)).Take(limit).ToList();
  51. foreach (var row in data)
  52. {
  53. dtUser.Rows.Add(row.UserId, row.UserName);
  54. }
  55. //var sText = data[0].UserName.ToString();
  56. //comboBox1.SelectionStart = name.Length;
  57. //comboBox1.SelectionLength = sText.Length - name.Length;
  58.  
  59. //comboBox1.Text = name;
  60. //comboBox1.DataSource = null;
  61. comboBox2.DataSource = dtUser;
  62. comboBox2.DisplayMember = "Name";
  63. comboBox2.ValueMember = "Key";
  64. comboBox2.DroppedDown = true;
  65. comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
  66. comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;
  67. comboBox1.DropDownStyle = ComboBoxStyle.DropDown;
  68. }
  69. }
  70. }
  71.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(5,14): error CS0234: The type or namespace name `Data' does not exist in the namespace `System'. Are you missing `System.Data' assembly reference?
prog.cs(9,22): error CS0234: The type or namespace name `Forms' does not exist in the namespace `System.Windows'. Are you missing `System.Windows.Forms' assembly reference?
prog.cs(10,7): error CS0246: The type or namespace name `MetroFramework' could not be found. Are you missing an assembly reference?
prog.cs(11,23): error CS0234: The type or namespace name `Models' does not exist in the namespace `Battery_Tracker'. Are you missing an assembly reference?
prog.cs(12,23): error CS0234: The type or namespace name `DAL' does not exist in the namespace `Battery_Tracker'. Are you missing an assembly reference?
prog.cs(13,7): error CS0246: The type or namespace name `MetroFramework' could not be found. Are you missing an assembly reference?
prog.cs(17,38): error CS0246: The type or namespace name `MetroUserControl' could not be found. Are you missing an assembly reference?
prog.cs(19,9): error CS0246: The type or namespace name `SqlDBContext' could not be found. Are you missing an assembly reference?
prog.cs(43,56): error CS0246: The type or namespace name `KeyPressEventArgs' could not be found. Are you missing an assembly reference?
Compilation failed: 9 error(s), 0 warnings
stdout
Standard output is empty