BookInfoExitRows_UI.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace Web
  11. {
  12. public partial class BookInfoExitRows_UI : Form
  13. {
  14. public BookInfoExitRows_UI()
  15. {
  16. InitializeComponent();
  17. }
  18. public BookInfoManager_UI Book = null;
  19. public ReaderManager_UI Reader = null;
  20. DataGridViewColumnCollection columns;
  21. private void BookInfoExitRows_UI_Load(object sender, EventArgs e)
  22. {
  23. if (Book != null)
  24. {
  25. columns = Book.dataGridView1.Columns;
  26. }
  27. else if (Reader != null)
  28. {
  29. columns = Reader.dgvHeaderInfo.Columns;
  30. }
  31. for (int i = 0; i < columns.Count - 2; i++)
  32. {
  33. if (columns[i].Visible == true)
  34. {
  35. listBox1.Items.Add(columns[i].HeaderText);
  36. }
  37. else
  38. {
  39. listBox2.Items.Add(columns[i].HeaderText);
  40. }
  41. }
  42. }
  43. //左移
  44. private void btnLeft_Click(object sender, EventArgs e)
  45. {
  46. ListBox.SelectedObjectCollection selectListBox2 = listBox2.SelectedItems;
  47. for (int i = 0; i < selectListBox2.Count; i++)
  48. {
  49. listBox1.Items.Add(selectListBox2[i]);
  50. for (int j = 0; j < columns.Count - 2; j++)
  51. {
  52. if (columns[j].HeaderText == selectListBox2[i].ToString())
  53. {
  54. columns[j].Visible = true;
  55. }
  56. }
  57. }
  58. ListBox.SelectedIndexCollection indices = listBox2.SelectedIndices;
  59. for (int i = indices.Count - 1; i >= 0; i--)
  60. {
  61. int index = indices[i];
  62. listBox2.Items.RemoveAt(index);
  63. }
  64. }
  65. //右移
  66. private void btnRight_Click(object sender, EventArgs e)
  67. {
  68. ListBox.SelectedObjectCollection selectListBox1 = listBox1.SelectedItems;
  69. for (int i = 0; i < selectListBox1.Count; i++)
  70. {
  71. listBox2.Items.Add(selectListBox1[i]);
  72. for (int j = 0; j < columns.Count - 2; j++)
  73. {
  74. if (columns[j].HeaderText == selectListBox1[i].ToString())
  75. {
  76. columns[j].Visible = false;
  77. }
  78. }
  79. }
  80. ListBox.SelectedIndexCollection indices = listBox1.SelectedIndices;
  81. for (int i = indices.Count - 1; i >= 0; i--)
  82. {
  83. int index = indices[i];
  84. listBox1.Items.RemoveAt(index);
  85. }
  86. }
  87. private void btnClose_Click(object sender, EventArgs e)
  88. {
  89. this.Close();
  90. }
  91. }
  92. }