• R/O
  • SSH
  • HTTPS

mlapplication: Commit


Commit MetaInfo

Revision57 (tree)
Time2017-01-29 08:49:43
Authoryukio_miura

Log Message

(empty log message)

Change Summary

Incremental Difference

--- trunk/ML.Controls/uc6DataGridViewNumColumn.vb (revision 0)
+++ trunk/ML.Controls/uc6DataGridViewNumColumn.vb (revision 57)
@@ -0,0 +1,692 @@
1+
2+''' <summary>
3+''' 【クラス名】uc6DataGridViewNumColumn
4+''' 【機能概要】拡張DataGridViewNumBoxColumn
5+''' </summary>
6+''' <history>
7+''' +------------+-----------+-----+-------------------------------------------+
8+''' |更新者 |日付 |連番 |変更内容 |
9+''' +------------+-----------+-----+-------------------------------------------+
10+''' y.miura 2017.01.29 001 新規作成
11+''' </history>
12+Public Class uc6DataGridViewNumColumn
13+ Inherits DataGridViewColumn
14+
15+ ''' <summary>コンストラクタ</summary>
16+ Public Sub New()
17+ MyBase.New(New uc6DataGridViewNumCell)
18+
19+ '' ソートモードをAutomaticとする
20+ Me.SortMode = DataGridViewColumnSortMode.Automatic
21+
22+ End Sub
23+
24+ ''' <summary>整数部桁数最大値</summary>
25+ Friend Const MAX_DECIMAL_DEGITS As Integer = 27
26+
27+ ''' <summary>整数部桁数最小値</summary>
28+ Friend Const MIN_DECIMAL_DEGITS As Integer = 0
29+
30+ ''' <summary>小数部桁数最大値</summary>
31+ Friend Const MAX_FLACTION_DEGITS As Integer = 10
32+
33+ ''' <summary>小数部桁数最小値</summary>
34+ Friend Const MIN_FLACTION_DEGITS As Integer = 0
35+
36+ ''' <summary>整数部桁数既定値</summary>
37+ Friend Const DEFALT_DECIMAL_DEGITS As Integer = 20
38+
39+ ''' <summary>少数部桁数既定値</summary>
40+ Friend Const DEFALT_FLACTION_DEGITS As Integer = 0
41+
42+ ''' <summary>表示処理実行中フラグ</summary>
43+ Private m_bCalcFlg As Boolean = False
44+
45+ ''' <summary>少数部桁数</summary>
46+ Private m_iFlacDegits As Integer = DEFALT_FLACTION_DEGITS
47+
48+ ''' <summary>整数部桁数</summary>
49+ Private m_iDecDegits As Integer = DEFALT_DECIMAL_DEGITS
50+
51+ ''' <summary>マイナス入力可能フラグ</summary>
52+ Private m_bMinasFlg As Boolean = False
53+
54+ ''' <summary>数値桁区切り文字表示フラグ</summary>
55+ Private m_bCommaFlg As Boolean = False
56+
57+ ''' <summary>ゼロ詰編集フラグ</summary>
58+ Private m_bZeroPaddingFlg As Boolean = False
59+
60+ ''' <summary>少数部桁数</summary>
61+ Public Property AfterDecimalDigits() As Integer
62+
63+ Get
64+ Return Me.m_iFlacDegits
65+ End Get
66+ Set(ByVal value As Integer)
67+ If value > MAX_FLACTION_DEGITS Then value = MAX_FLACTION_DEGITS
68+ If value < MIN_FLACTION_DEGITS Then value = MIN_FLACTION_DEGITS
69+ Me.m_iFlacDegits = value
70+ End Set
71+
72+ End Property
73+
74+ ''' <summary>ゼロ詰編集フラグ</summary>
75+ Public Property AfterDecimalZeroPadding() As Boolean
76+
77+ Get
78+ Return Me.m_bZeroPaddingFlg
79+ End Get
80+ Set(ByVal value As Boolean)
81+ Me.m_bZeroPaddingFlg = value
82+ End Set
83+
84+ End Property
85+
86+ ''' <summary>整数部桁数</summary>
87+ Public Property DecimalDigits() As Integer
88+
89+ Get
90+ Return Me.m_iDecDegits
91+ End Get
92+ Set(ByVal value As Integer)
93+ If value > MAX_DECIMAL_DEGITS Then value = MAX_DECIMAL_DEGITS
94+ If value < MIN_DECIMAL_DEGITS Then value = MIN_DECIMAL_DEGITS
95+ Me.m_iDecDegits = value
96+ End Set
97+
98+ End Property
99+
100+ ''' <summary>マイナス値入力の許可</summary>
101+ Public Property NegativeSignInput() As Boolean
102+
103+ Get
104+ Return Me.m_bMinasFlg
105+ End Get
106+ Set(ByVal value As Boolean)
107+ Me.m_bMinasFlg = value
108+ End Set
109+
110+ End Property
111+
112+ ''' <summary>カンマセパレーターの有無</summary>
113+ Public Property CommaFormat() As Boolean
114+
115+ Get
116+ Return Me.m_bCommaFlg
117+ End Get
118+ Set(ByVal value As Boolean)
119+ Me.m_bCommaFlg = value
120+ End Set
121+
122+ End Property
123+
124+ ''' <summary>CellTemplate</summary>
125+ ''' <returns>CellTemplate</returns>
126+ Public Overrides Property CellTemplate() As DataGridViewCell
127+ Get
128+ Return MyBase.CellTemplate
129+ End Get
130+ Set(ByVal value As DataGridViewCell)
131+ MyBase.CellTemplate = value
132+ End Set
133+ End Property
134+
135+ ''' <summary>Clone</summary>
136+ ''' <remarks>
137+ ''' 必要なメソッドがなかったため追加
138+ ''' 新しいプロパティを追加しているため、
139+ ''' Cloneメソッドをオーバーライドする必要がある
140+ ''' </remarks>
141+ Public Overrides Function Clone() As Object
142+ Dim col As uc6DataGridViewNumColumn =
143+ DirectCast(MyBase.Clone(), uc6DataGridViewNumColumn)
144+ col.m_bCalcFlg = Me.m_bCalcFlg
145+ col.m_iFlacDegits = Me.m_iFlacDegits
146+ col.m_iDecDegits = Me.m_iDecDegits
147+ col.m_bMinasFlg = Me.m_bMinasFlg
148+ col.m_bCommaFlg = Me.m_bCommaFlg
149+ col.m_bZeroPaddingFlg = Me.m_bZeroPaddingFlg
150+ Return col
151+ End Function
152+
153+End Class
154+
155+''' <summary>
156+''' 【クラス名】uc6DataGridViewNumCell
157+''' 【機能概要】拡張DataGridViewNumBoxCell
158+''' </summary>
159+''' <history>
160+''' +------------+-----------+-----+-------------------------------------------+
161+''' |更新者 |日付 |連番 |変更内容 |
162+''' +------------+-----------+-----+-------------------------------------------+
163+''' y.miura 2017.01.29 001 新規作成
164+''' </history>
165+Public Class uc6DataGridViewNumCell
166+ Inherits DataGridViewTextBoxCell
167+
168+ ''' <summary>コンストラクタ</summary>
169+ Public Sub New()
170+ MyBase.New()
171+ End Sub
172+
173+ ''' <summary>
174+ ''' 編集コントロールを初期化する
175+ ''' 編集コントロールは別のセルや列でも使いまわされるため、初期化の必要がある
176+ ''' </summary>
177+ ''' <param name="iRowIdx">行インデックス</param>
178+ ''' <param name="oFormatted">値</param>
179+ ''' <param name="dgvCellStyle">セルスタイル</param>
180+ Public Overrides Sub InitializeEditingControl( _
181+ ByVal iRowIdx As Integer, _
182+ ByVal oFormatted As Object, _
183+ ByVal dgvCellStyle As DataGridViewCellStyle)
184+
185+ MyBase.InitializeEditingControl(iRowIdx, oFormatted, dgvCellStyle)
186+
187+ '' 編集コントロールの取得
188+ Dim uc6Num As uc6DataGridViewNumEditingControl = _
189+ TryCast(Me.DataGridView.EditingControl, uc6DataGridViewNumEditingControl)
190+
191+ If uc6Num IsNot Nothing Then
192+ '' 値を文字列に変換
193+ Dim formattedValu As String = TryCast(oFormatted, String)
194+ uc6Num.DecimalPointDigit = Me.AfterDecimaldigits
195+ uc6Num.DecimalPointZeroPadding = Me.m_ZeroPadding
196+ uc6Num.IntegerDigit = Me.DecimalDigits
197+ uc6Num.NegativeSign = Me.NegativeSign_Input
198+ uc6Num.CommaFormat = Me.CommaNeed
199+ uc6Num.Text = If(formattedValu IsNot Nothing, formattedValu.Replace(",", ""), "")
200+ End If
201+
202+ End Sub
203+
204+ ''' <summary>セルに値を入れる</summary>
205+ ''' <param name="iRowIdx">行インデックス</param>
206+ ''' <param name="oCellValue">セル値</param>
207+ Protected Overrides Function SetValue(iRowIdx As Integer, _
208+ oCellValue As Object) As Boolean
209+ If IsNothing(oCellValue) OrElse IsDBNull(oCellValue) Then
210+ Else
211+ Dim dCellValue As Decimal
212+ If Decimal.TryParse(oCellValue, dCellValue) Then
213+
214+ Dim sFmt As String = "0"
215+ If Me.CommaNeed = True Then
216+ sFmt = "#," & sFmt
217+ End If
218+ If Me.AfterDecimaldigits > 0 Then
219+ Dim sFmtAfter As String
220+ If Me.m_ZeroPadding Then
221+ sFmtAfter = "." & New String("0", Me.AfterDecimaldigits)
222+ Else
223+ sFmtAfter = "." & New String("#", Me.AfterDecimaldigits)
224+ End If
225+ sFmt &= sFmtAfter
226+ End If
227+ oCellValue = dCellValue.ToString(sFmt)
228+ Else
229+ oCellValue = Nothing
230+ End If
231+ End If
232+
233+ Return MyBase.SetValue(iRowIdx, oCellValue)
234+ End Function
235+
236+ ''' <summary>編集コントロールの型プロパティ</summary>
237+ ''' <returns>編集コントロールの型</returns>
238+ Public Overrides ReadOnly Property EditType() As Type
239+ Get
240+ Return GetType(uc6DataGridViewNumEditingControl)
241+ End Get
242+ End Property
243+
244+ ''' <summary>Booleanの項目の設定に使用します</summary>
245+ Enum SetState As Integer
246+
247+ ''' <summary>カラムの設定に従います。</summary>
248+ NotSet = 0
249+
250+ ''' <summary>Trueの値を設定します</summary>
251+ Need = 1
252+
253+ ''' <summary>Falseの値を設定します</summary>
254+ NotNeed = 2
255+
256+ End Enum
257+
258+#Region " カンマ"
259+
260+ ''' <summary>カンマの要否</summary>
261+ Private m_CommaFormat As SetState = SetState.NotSet
262+
263+ ''' <summary>カンマが必要かどうかセルごとに設定を行います</summary>
264+ ''' <value>設定する値</value>
265+ Public Property CommaFormat As SetState
266+ Set(value As SetState)
267+ Me.m_CommaFormat = value
268+ End Set
269+ Get
270+ Return Me.m_CommaFormat
271+ End Get
272+ End Property
273+
274+ ''' <summary>このセルにカンマが必要かどうか設定を取得します</summary>
275+ Private ReadOnly Property CommaNeed As Boolean
276+ Get
277+ Select Case Me.m_CommaFormat
278+ Case SetState.NotSet
279+ Dim uc6NumCol As uc6DataGridViewNumColumn = _
280+ TryCast(Me.OwningColumn, uc6DataGridViewNumColumn)
281+ If uc6NumCol IsNot Nothing Then
282+ Return uc6NumCol.CommaFormat
283+ Else
284+ Return True
285+ End If
286+ Case SetState.NotNeed
287+ Return False
288+ Case Else
289+ Return True
290+ End Select
291+ End Get
292+ End Property
293+
294+#End Region
295+
296+#Region " ゼロパディング"
297+
298+ ''' <summary>
299+ ''' ゼロパディングの適用要否 
300+ ''' </summary>
301+ Public Property ZeroPadding As SetState = SetState.NotSet
302+
303+ ''' <summary>
304+ ''' ゼロパディングの適用要否 
305+ ''' </summary>
306+ Private ReadOnly Property m_ZeroPadding As Boolean
307+ Get
308+ Select Case Me.ZeroPadding
309+ Case SetState.NotSet
310+ Dim uc6Num As uc6DataGridViewNumColumn = _
311+ TryCast(Me.OwningColumn, uc6DataGridViewNumColumn)
312+ If uc6Num IsNot Nothing Then
313+ Return uc6Num.AfterDecimalZeroPadding
314+ Else
315+ Return False
316+ End If
317+ Case SetState.Need
318+ Return True
319+ Case Else
320+ Return False
321+ End Select
322+ End Get
323+ End Property
324+
325+#End Region
326+
327+#Region " 整数桁数"
328+
329+ ''' <summary>整数部桁数</summary>
330+ Private m_iDecimalDigits As Integer = -1
331+
332+ ''' <summary>整数部の最大桁数</summary>
333+ ''' <remarks>最大27 負の数を設定した場合カラムの設定に従います</remarks>
334+ Public Property DecimalDigits As Integer
335+ Set(value As Integer)
336+ If Me.AfterDecimaldigits + value > uc6DataGridViewNumColumn.MAX_DECIMAL_DEGITS Then
337+ value = uc6DataGridViewNumColumn.MAX_DECIMAL_DEGITS - (Me.AfterDecimaldigits)
338+ End If
339+ Me.m_iDecimalDigits = value
340+ End Set
341+ Get
342+ If Me.m_iDecimalDigits < 0 Then
343+ Dim uc6Num As uc6DataGridViewNumColumn = _
344+ TryCast(Me.OwningColumn, uc6DataGridViewNumColumn)
345+ If uc6Num IsNot Nothing Then
346+ Return uc6Num.DecimalDigits
347+ Else
348+ Return uc6DataGridViewNumColumn.DEFALT_DECIMAL_DEGITS
349+ End If
350+ Else
351+ Return Me.m_iDecimalDigits
352+ End If
353+ End Get
354+ End Property
355+
356+#End Region
357+
358+#Region " 少数部桁数"
359+
360+ ''' <summary>少数部桁数</summary>
361+ Private m_AfterDecimaldigits As Integer = -1
362+
363+ ''' <summary>少数の最大桁数</summary>
364+ ''' <remarks>負の数を設定した場合カラムの設定に従います</remarks>
365+ Public Property AfterDecimaldigits As Integer
366+ Set(value As Integer)
367+ If value + DecimalDigits > uc6DataGridViewNumColumn.MAX_DECIMAL_DEGITS Then
368+ Me.m_AfterDecimaldigits = uc6DataGridViewNumColumn.MAX_DECIMAL_DEGITS - DecimalDigits
369+ Else
370+ Me.m_AfterDecimaldigits = value
371+ End If
372+ End Set
373+ Get
374+ If Me.m_AfterDecimaldigits < 0 Then
375+ Dim uc6Num As uc6DataGridViewNumColumn = _
376+ TryCast(Me.OwningColumn, uc6DataGridViewNumColumn)
377+ If uc6Num IsNot Nothing Then
378+ Return uc6Num.AfterDecimalDigits
379+ Else
380+ Return uc6DataGridViewNumColumn.DEFALT_FLACTION_DEGITS
381+ End If
382+ Else
383+ Return Me.m_AfterDecimaldigits
384+ End If
385+ End Get
386+ End Property
387+
388+#End Region
389+
390+#Region " 負の数"
391+
392+ ''' <summary>負の数を入力できるかどうか設定します</summary>
393+ Public Property NegativeSignInput As SetState = SetState.NotSet
394+
395+ ''' <summary>負の数を入力できるかどうか設定します</summary>
396+ Private ReadOnly Property NegativeSign_Input As Boolean
397+ Get
398+ Select Case ZeroPadding
399+ Case SetState.NotSet
400+ Dim uc6Num As uc6DataGridViewNumColumn = _
401+ TryCast(Me.OwningColumn, uc6DataGridViewNumColumn)
402+ If uc6Num IsNot Nothing Then
403+ Return uc6Num.NegativeSignInput
404+ Else
405+ Return False
406+ End If
407+ Case SetState.Need
408+ Return True
409+ Case Else
410+ Return False
411+ End Select
412+ End Get
413+ End Property
414+
415+#End Region
416+
417+ ''' <summary>Clone</summary>
418+ Public Overrides Function Clone() As Object
419+ Dim Cell As uc6DataGridViewNumCell = DirectCast(MyBase.Clone(), uc6DataGridViewNumCell)
420+ Cell.CommaFormat = Me.CommaFormat
421+ Cell.ZeroPadding = Me.ZeroPadding
422+ Cell.DecimalDigits = Me.m_iDecimalDigits
423+ Cell.AfterDecimaldigits = Me.m_AfterDecimaldigits
424+ Cell.NegativeSignInput = Me.NegativeSignInput
425+ Return Cell
426+ End Function
427+
428+End Class
429+
430+''' <summary>
431+''' 【クラス名】uc6DataGridViewNumEditingControl
432+''' 【機能概要】拡張uc6Num
433+''' </summary>
434+''' <history>
435+''' +------------+-----------+-----+-------------------------------------------+
436+''' |更新者 |日付 |連番 |変更内容 |
437+''' +------------+-----------+-----+-------------------------------------------+
438+''' y.miura 2017.01.29 001 新規作成
439+''' </history>
440+Public Class uc6DataGridViewNumEditingControl
441+ Inherits uc6Num
442+ Implements IDataGridViewEditingControl
443+
444+ ''' <summary>編集コントロールが表示されているdataGridView</summary>
445+ Private m_dgvMe As DataGridView
446+
447+ ''' <summary>編集コントロールが表示されている行</summary>
448+ Private m_iRowIdx As Integer
449+
450+ ''' <summary>編集コントロールの値とセルの値が違うかどうか</summary>
451+ Private m_bValueDiffFlg As Boolean
452+
453+ ''' <summary>コンストラクタ</summary>
454+ Public Sub New()
455+ Me.TabStop = False
456+ End Sub
457+
458+#Region "IDataGridViewEditingControl メンバ"
459+
460+ ''' <summary>編集コントロールで変更されたセルの値</summary>
461+ ''' <param name="context">DataGridViewDataErrorContexts</param>
462+ Public Function GetEditingControlFormattedValue( _
463+ ByVal context As DataGridViewDataErrorContexts) As Object _
464+ Implements IDataGridViewEditingControl.GetEditingControlFormattedValue
465+
466+ Return Me.Text
467+ End Function
468+
469+ ''' <summary>編集コントロールで変更されたセルの値のプロパティ</summary>
470+ ''' <value>編集コントロールで変更されたセルの値</value>
471+ ''' <returns>編集コントロールで変更されたセルの値</returns>
472+ Public Property EditingControlFormattedValue() As Object _
473+ Implements IDataGridViewEditingControl.EditingControlFormattedValue
474+
475+ Get
476+ Return Me.GetEditingControlFormattedValue( _
477+ DataGridViewDataErrorContexts.Formatting)
478+ End Get
479+ Set(ByVal value As Object)
480+ Me.Text = DirectCast(value, String)
481+ End Set
482+ End Property
483+
484+ ''' <summary>
485+ ''' セルスタイルを編集コントロールに適用する
486+ ''' 編集コントロールの前景色、背景色、フォントなどをセルスタイルに合わせる
487+ ''' </summary>
488+ ''' <param name="cellStyle">セルスタイル</param>
489+ Public Sub ApplyCellStyleToEditingControl(ByVal cellStyle As DataGridViewCellStyle) _
490+ Implements IDataGridViewEditingControl.ApplyCellStyleToEditingControl
491+
492+ ' フォント・色の設定
493+ Me.Font = cellStyle.Font
494+ Me.ForeColor = cellStyle.ForeColor
495+ Me.BackColor = cellStyle.BackColor
496+
497+ ' 表示位置の設定
498+ Select Case cellStyle.Alignment
499+ Case DataGridViewContentAlignment.BottomCenter, _
500+ DataGridViewContentAlignment.MiddleCenter, _
501+ DataGridViewContentAlignment.TopCenter
502+
503+ Me.TextAlign = HorizontalAlignment.Center
504+ Exit Select
505+ Case DataGridViewContentAlignment.BottomRight, _
506+ DataGridViewContentAlignment.MiddleRight, _
507+ DataGridViewContentAlignment.TopRight
508+
509+ Me.TextAlign = HorizontalAlignment.Right
510+ Exit Select
511+ Case Else
512+ Me.TextAlign = HorizontalAlignment.Left
513+ Exit Select
514+ End Select
515+ End Sub
516+
517+ ''' <summary>編集するセルがあるDataGridViewのプロパティ</summary>
518+ ''' <value>編集するセルがあるDataGridView</value>
519+ ''' <returns>編集するセルがあるDataGridView</returns>
520+ Public Property EditingControlDataGridView() As DataGridView _
521+ Implements IDataGridViewEditingControl.EditingControlDataGridView
522+
523+ Get
524+ Return Me.m_dgvMe
525+ End Get
526+ Set(ByVal value As DataGridView)
527+ Me.m_dgvMe = value
528+ End Set
529+ End Property
530+
531+ ''' <summary>編集している行のインデックスのプロパティ</summary>
532+ ''' <value>編集している行のインデックス</value>
533+ ''' <returns>編集している行のインデックス</returns>
534+ Public Property EditingControlRowIndex() As Integer _
535+ Implements IDataGridViewEditingControl.EditingControlRowIndex
536+
537+ Get
538+ Return Me.m_iRowIdx
539+ End Get
540+ Set(ByVal value As Integer)
541+ Me.m_iRowIdx = value
542+ End Set
543+ End Property
544+
545+ ''' <summary>編集コントロールの値とセルの値が違うかどうかのプロパティ</summary>
546+ ''' <value>編集コントロールの値とセルの値が違うかどうか</value>
547+ ''' <returns>編集コントロールの値とセルの値が違うかどうか</returns>
548+ Public Property EditingControlValueChanged() As Boolean _
549+ Implements IDataGridViewEditingControl.EditingControlValueChanged
550+
551+ Get
552+ Return Me.m_bValueDiffFlg
553+ End Get
554+ Set(ByVal value As Boolean)
555+ Me.m_bValueDiffFlg = value
556+ End Set
557+ End Property
558+
559+ ''' <summary>指定されたキーをDataGridViewが処理するか、編集コントロールが処理するか</summary>
560+ ''' <param name="keyData">キーコード</param>
561+ ''' <param name="inputKey"></param>
562+ Public Function EditingControlWantsInputKey(ByVal keyData As Keys, _
563+ ByVal inputKey As Boolean) As Boolean _
564+ Implements IDataGridViewEditingControl.EditingControlWantsInputKey
565+
566+ ' Keys.Left、Right、Home、Endの時は、Trueを返す
567+ ' このようにしないと、これらのキーで別のセルにフォーカスが移ってしまう
568+ Select Case keyData And Keys.KeyCode
569+ Case Keys.Right, Keys.[End], Keys.Left, Keys.Home
570+ Return True
571+ Case Else
572+ Return Not inputKey
573+ End Select
574+ End Function
575+
576+ ''' <summary>マウスカーソルがEditingPanel上にあるときのカーソルのプロパティ</summary>
577+ ''' <returns>マウスカーソルがEditingPanel上にあるときのカーソル</returns>
578+ Public ReadOnly Property EditingPanelCursor() As Cursor _
579+ Implements IDataGridViewEditingControl.EditingPanelCursor
580+
581+ Get
582+ Return MyBase.Cursor
583+ End Get
584+ End Property
585+
586+ ''' <summary>
587+ ''' コントロールで編集する準備をする
588+ ''' テキストを選択状態にしたり、挿入ポインタを末尾にしたりする
589+ ''' </summary>
590+ ''' <param name="bSelectAll">選択状態</param>
591+ Public Sub PrepareEditingControlForEdit(ByVal bSelectAll As Boolean) _
592+ Implements IDataGridViewEditingControl.PrepareEditingControlForEdit
593+
594+ If bSelectAll Then
595+ '' 選択状態にする
596+ Me.SelectAll()
597+ Else
598+ '' 挿入ポインタを末尾にする
599+ Me.SelectionStart = Me.TextLength
600+ End If
601+ End Sub
602+
603+ ''' <summary>値が変更した時に、セルの位置を変更するかどかのプロパティ</summary>
604+ ''' <returns>値が変更した時に、セルの位置を変更するかどうか</returns>
605+ Public ReadOnly Property RepositionEditingControlOnValueChange() As Boolean _
606+ Implements IDataGridViewEditingControl.RepositionEditingControlOnValueChange
607+
608+ Get
609+ Return False
610+ End Get
611+ End Property
612+
613+#End Region
614+
615+ ''' <summary>値が変更された時</summary>
616+ Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
617+ MyBase.OnTextChanged(e)
618+
619+ '' 値が変更されたことをDataGridViewに通知する
620+ Me.m_bValueDiffFlg = True
621+ Me.m_dgvMe.NotifyCurrentCellDirty(True)
622+ End Sub
623+
624+ ''' <summary>フォーカスを取得した時</summary>
625+ Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
626+ MyBase.OnGotFocus(e)
627+ End Sub
628+
629+ ''' <summary>フォーカスを喪失した時</summary>
630+ Protected Overrides Sub OnLostFocus(ByVal e As System.EventArgs)
631+ MyBase.OnLostFocus(e)
632+ End Sub
633+
634+ ''' <summary>キー押下時</summary>
635+ Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
636+ If e.KeyCode = Keys.Right Then
637+ '' 「→」キー押下
638+ If Me.SelectionLength = 0 AndAlso Me.SelectionStart = Me.Text.Length Then
639+ Dim iColIdx As Integer = Me.m_dgvMe.CurrentCell.ColumnIndex
640+ If iColIdx < Me.m_dgvMe.ColumnCount - 1 Then
641+ MyBase.OnKeyDown(e)
642+ If e.Handled = True Then Exit Sub
643+
644+ Dim dgv As DataGridView = Me.m_dgvMe
645+ Dim iColIndexOffSet As Integer = 1
646+ Dim iColIndexNow As Integer = dgv.CurrentCellAddress.X + iColIndexOffSet
647+ Do Until iColIndexNow > Me.m_dgvMe.ColumnCount - 1
648+
649+ Dim dgc As DataGridViewCell = dgv(iColIndexNow, dgv.CurrentCellAddress.Y)
650+ If dgc.Visible = True Then
651+ dgv.CurrentCell = dgv(iColIndexNow, dgv.CurrentCellAddress.Y)
652+ Exit Sub
653+ End If
654+ iColIndexOffSet += 1
655+ iColIndexNow = dgv.CurrentCellAddress.X + iColIndexOffSet
656+
657+ Loop
658+
659+ Exit Sub
660+ End If
661+ End If
662+ ElseIf e.KeyCode = Keys.Left Then
663+ '' 「←」キー押下
664+ If Me.SelectionLength = 0 AndAlso Me.SelectionStart = 0 Then
665+ Dim iColIdx As Integer = Me.m_dgvMe.CurrentCell.ColumnIndex
666+ If iColIdx > 0 Then
667+ MyBase.OnKeyDown(e)
668+ If e.Handled = True Then Exit Sub
669+
670+ Dim dgv As DataGridView = Me.m_dgvMe
671+ Dim iColIndexOffSet As Integer = -1
672+ Dim iColIndexNow As Integer = dgv.CurrentCellAddress.X + iColIndexOffSet
673+ Do Until iColIndexNow < 0
674+
675+ Dim dgc As DataGridViewCell = dgv(iColIndexNow, dgv.CurrentCellAddress.Y)
676+ If dgc.Visible = True Then
677+ dgv.CurrentCell = dgv(iColIndexNow, dgv.CurrentCellAddress.Y)
678+ Exit Sub
679+ End If
680+ iColIndexOffSet -= 1
681+ iColIndexNow = dgv.CurrentCellAddress.X + iColIndexOffSet
682+
683+ Loop
684+
685+ Exit Sub
686+ End If
687+ End If
688+ End If
689+ MyBase.OnKeyDown(e)
690+ End Sub
691+
692+End Class
Show on old repository browser