PageRenderTime 99ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Visual Studio 2008/VBWinFormDataGridView/EditingControlHosting/ReadMe.txt

#
Plain Text | 74 lines | 46 code | 28 blank | 0 comment | 0 complexity | 6169526c2760a6cd130cbdd0013d1f16 MD5 | raw file
  1. ================================================================================
  2. WINDOWS FORMS APPLICATION : VBWinFormDataGridView Project Overview
  3. EditingControlHosting Sample
  4. ===============================================================================
  5. /////////////////////////////////////////////////////////////////////////////
  6. Use:
  7. This sample demonstrates how to host a control in the current DataGridViewCell
  8. for editing.
  9. /////////////////////////////////////////////////////////////////////////////
  10. Remark:
  11. There're six standard DataGridViewColumn types for use as follows:
  12. DataGridViewTextBoxColumn
  13. DataGridViewCheckedBoxColumn
  14. DataGridViewComboBoxColumn
  15. DataGridViewLinkColumn
  16. DataGridViewButtonColumn
  17. DataGridViewImageColumn
  18. However, developers may want to use a different control for editing on the column,
  19. e.g. MarkedTextBox, DateTimePicker etc. This feature can be achieved in two ways:
  20. 1. Create a custom DataGridViewColumn;
  21. For the details of how to do this, please refer to the CustomDataGridViewColumn
  22. sample.
  23. 2. Place the editing control on the current cell when editing begins, and hide
  24. the editing control when the editing completes.
  25. This sample demonstrates how to do this.
  26. /////////////////////////////////////////////////////////////////////////////
  27. Code Logic:
  28. 1. Create an instance of the editing control, in this sample the editing control
  29. is MaskedTextBox.
  30. 2. Specify a mask for the MaskedTextBox and add the MaskedTextBox to the
  31. control collection of the DataGridView;
  32. 3. Hide the MaskedTextBox;
  33. 4. Handle the CellBeginEdit event to show the MaskedTextBox on the current
  34. editing cell;
  35. 5. Handle the CellEndEdit event to hide the MaskedTextBox when editing completes;
  36. 6. Handle the Scroll event to adjust the location of the MaskedTextBox as it is
  37. showing when scrolling the DataGridView;
  38. 7. Handle the EditingControlShowing event to pass the focus to the MaskedTextBox
  39. when begin editing with keystrokes;
  40. /////////////////////////////////////////////////////////////////////////////
  41. References:
  42. 1. DataGridView Class
  43. http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx
  44. 2. Windows Forms FAQs
  45. http://windowsclient.net/blogs/faqs/archive/tags/Custom+Designers/default.aspx
  46. /////////////////////////////////////////////////////////////////////////////