- - PR -
DataGridでのTabキー押下処理を変更するには
投稿者 | 投稿内容 |
---|---|
|
投稿日時: 2003-11-06 19:20
KeroKeroさん追加情報ありがとうございます。
教えていただいた通り Me.MyDataGrid1=New MyDataGrid() Me.MydataGrid1.NextControl=Button3 を追加したのですが、 Me.MydataGrid1.NextControl=Button3 がコンパイルエラーで引っかかってしまいます。 エラーメッセージは「NextControlは'System.Windows.Forms.DataGrid'のメンバではありません」 と出ています。 初歩的な事のように思えますが、何しろ初心者ですのでよくわかりません。 こちらの解決方法についても教えていただければと思います。 |
|
投稿日時: 2003-11-07 09:52
これでどうでしょう。Form1_Load内で処理するように変えてみました。
ちなみに,別途にデザイナでButton1〜3を貼り付けてます。 Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows フォーム デザイナで生成されたコード " Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim MyDataGrid1 As New MyDataGrid() Dim ds As New DataSet() Dim tb As DataTable = ds.Tables.Add("Table01") Dim col1 As DataColumn = tb.Columns.Add("Column01") Dim col2 As DataColumn = tb.Columns.Add("Column02") tb.Rows.Add(New String() {"あいうえお", "かきくけこ"}) tb.Rows.Add(New String() {"さしすせそ", "たちつてと"}) MyDataGrid1.DataSource = ds MyDataGrid1.DataMember = "Table01" MyDataGrid1.Location = New System.Drawing.Point(8, 56) MyDataGrid1.Name = "DataGrid1" MyDataGrid1.Size = New System.Drawing.Size(272, 176) MyDataGrid1.TabIndex = 3 MyDataGrid1.NextControl = Button3 Me.Controls.Add(MyDataGrid1) End Sub End Class Public Class MyDataGrid Inherits System.Windows.Forms.DataGrid Const WM_KEYDOWN As Integer = &H100 Private mControl As Windows.Forms.Control Public Property NextControl() As Control Get Return mControl End Get Set(ByVal Value As Control) mControl = Value End Set End Property Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, _ ByVal keyData As System.Windows.Forms.Keys) As Boolean If msg.Msg = WM_KEYDOWN Then If (keyData = Keys.Tab) Then mControl.Focus() Return (True) Else Return MyBase.ProcessCmdKey(msg, keyData) End If End If Return MyBase.ProcessCmdKey(msg, keyData) End Function End Class |
|
投稿日時: 2003-11-07 10:25
KeroKeroさん度々のアドバイスどうもありがとうございます。
教えて頂いたコードでようやく動作させる事が出来ました。 これから自分の以前書いたコードと比較して何が悪かったのか原因究明してみようと思います。 一週間がかりでようやく解決する事が出来ました。感謝しております。 ありがとうございました。 |