PageRenderTime 18ms CodeModel.GetById 16ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

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

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