PDA

View Full Version : سوال: چگونه در vb.net->data gerit view کاری کنیم که با زدن دکمه اینتر به سطر بعدی نرود ؟؟



mohsen gh
یک شنبه 19 اردیبهشت 1389, 14:43 عصر
چگونه در vb.net->data gerit view کاری کنیم که با زدن دکمه اینتر به سطر بعدی نرود و در همان سطر بماند ؟؟

spring69
دوشنبه 20 اردیبهشت 1389, 00:24 صبح
سلام.
در رویداد KeyDown مربوط به Datagridview این کد رو بنویس:

If e.KeyData = Keys.Return Then e.Handled = True

DoDoklak
دوشنبه 20 اردیبهشت 1389, 18:40 عصر
در رویداد KeyDown مربوط به Datagridview این کد رو بنویس:


view source (http://barnamenevis.org/forum/#viewSource)
print (http://barnamenevis.org/forum/#printSource)? (http://barnamenevis.org/forum/#about)

1.If e.KeyData = Keys.Return Then e.Handled = True



البته این روش فقط زمانی به درد میخوره که تو دیتا گرید تایپ نکنی در غیر اینصورت جواب نمیده

hooooman
سه شنبه 21 اردیبهشت 1389, 16:21 عصر
PublicClass DGV
Inherits System.Windows.Forms.DataGridView
Dim new_row AsInteger

Private m_EditingRow AsInteger = -1
Private srt AsString
Private _Unvisibles AsInteger
Dim currentvalue AsObject
Dim _forms AsInteger
Dim _kind AsInteger
Dim _metag AsInteger
Dim curentrow AsInteger
PublicProperty forms()
Get
Return _forms
EndGet
Set(ByVal value)
_forms = value
EndSet
EndProperty
PrivateSub MyDataGridViewSanad_EditingControlShowing(ByVal sender AsObject, ByVal e As System.Windows.Forms.DataGridViewEditingControlSho wingEventArgs) HandlesMe.EditingControlShowing
m_EditingRow = Me.CurrentRow.Index
EndSub
PrivateSub MyDataGridViewSanad_KeyDown(ByVal sender AsObject, ByVal e As System.Windows.Forms.KeyEventArgs) HandlesMe.KeyDown
EndSub
PrivateSub DGV_SelectionChanged(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMe.SelectionChanged
IfNotMe.RowCount = 0 Then
If m_EditingRow >= 0 Then
new_row = m_EditingRow
Me.CurrentCell = Me.Rows(new_row).Cells(Me.CurrentCell.ColumnIndex)
m_EditingRow = -1
EndIf
EndIf
EndSub
PublicFunction CellCount(ByVal argoman AsObject, ByVal ColumnName AsString) AsInteger
Dim dgw As DataGridViewRow
Dim indx AsInteger = 0
ForEach dgw InMe.Rows
If dgw.Cells(ColumnName).Value = argoman Then
indx += 1
EndIf
Next
Return indx
EndFunction
PublicFunction Find(ByVal argoman AsObject, ByVal ColumnName AsString) AsInteger
Dim dgw As DataGridViewRow
Dim indx AsInteger = -1
ForEach dgw InMe.Rows
If dgw.Cells(ColumnName).Value = argoman Then
indx = dgw.Index
ExitFor
EndIf
Next
Return indx
EndFunction
PublicFunction Sum(ByVal ColumnName AsString) AsDouble
Dim dgw As DataGridViewRow
Dim sumantion AsDouble
ForEach dgw InMe.Rows
sumantion = sumantion + dgw.Cells(ColumnName).Value
Next
Return sumantion
EndFunction
PublicFunction Max(ByVal ColumnName AsString) AsDouble
Dim dgw As DataGridViewRow
Dim _max AsDouble = 0
ForEach dgw InMe.Rows
If _max < Val(Me.CurrentRow.Cells(ColumnName).Value) Then
_max = Val(Me.CurrentRow.Cells(ColumnName).Value)
EndIf
Next
Return _max
EndFunction

End


Class




سلام از اين کلاس DataGridVew استفاده کن
1 امکاناتي مثل جستجو و جمع ستون و ... هم داره
اون پراپرتي forms هم براي اينه که اگه 1 باشه بعد از اينکه به ستون آخر رديف رسيد فوکوس به کنترل بعدي بره و اگه 2 باشه نره