PDA

View Full Version : ماکس در DataGridView دات نت 2005



mhddns
دوشنبه 30 مرداد 1385, 21:35 عصر
من در پروژه خود احتیاج دارم یک ستون خاص از DataGridView که محل نمایش تاریخ می باشد به صورت"__/__/__" ماکس شود.
اگر دوستان می توانند مرا راهنمایی کند ممنون می شوم.:گریه:

sharifat
شنبه 02 بهمن 1389, 22:10 عصر
منم دقيقاً همين سوال رو دارم
اما اين تاپيك برا سال 1385 بوده كسي هم جواب نداده
يعني كسي پيدا ميشه اينو جواب بده؟؟؟؟؟؟؟؟؟؟؟:گریه::گریه:

alimanam
شنبه 02 بهمن 1389, 23:53 عصر
منم دقيقاً همين سوال رو دارم
اما اين تاپيك برا سال 1385 بوده كسي هم جواب نداده
يعني كسي پيدا ميشه اينو جواب بده؟؟؟؟؟؟؟؟؟؟؟:گریه::گریه:
من در پروژه خود احتیاج دارم یک ستون خاص از DataGridView که محل نمایش تاریخ می باشد به صورت"__/__/__" ماکس شود.
اگر دوستان می توانند مرا راهنمایی کند ممنون می شوم.:گریه:با سلام

ماشاا... به این همه صبر !!! یعنی واقعاً نتونستین مشکلتون رو با سرچ کردن حل کنید ؟ :متفکر::متفکر::متفکر:

sharifat
یک شنبه 03 بهمن 1389, 07:32 صبح
با سلام

ماشاا... به این همه صبر !!! یعنی واقعاً نتونستین مشکلتون رو با سرچ کردن حل کنید ؟ :متفکر::متفکر::متفکر:

سلام آقاي علي
من خيلي جستجو كردم نمونه اش هم همين تاپيك هستش. اين تاپيك قبلاً توسط شخص ديگه اي مطرح شده اما الان همين مشكل برا من هم پيش اومده
و گرنه من اصلاً هم صبر ندارم

و اما جوابي كه شما داديد
من جوابي شبيه جواب شما رو چند جاي ديگه هم ديدم
اما من اصلا MaskedTextBoxColumn ندارم.اين كلاس ناشناس هست
من نمي دونم بايد چيز خاصي اضاف كنم به برنامه ؟؟ يا اينكه چون من با ورژن 2005 كار مي كنم اين مشكل وجود داره؟؟؟
بعضي از دوستان هم كار با Format رو پيشنهاد كردن. اون روش براي زماني كه اطلاعات از بانك به ديتا بيس ريخته ميشه شايد خوب باشه
اما من مي خوام اطلاعاتم رو از گريد تو بانك ذخيره كنم
خواهش مي كنم كمك كنيد كلافه شدم

sharifat
یک شنبه 03 بهمن 1389, 09:22 صبح
با سلام

ماشاا... به این همه صبر !!! یعنی واقعاً نتونستین مشکلتون رو با سرچ کردن حل کنید ؟ :متفکر::متفکر::متفکر:

بابا دمتون گرم
خيلي با حاليد :لبخند:
من چون 2005 رو سيستمم بود برنامه شما رو نمي تونستم كامل ببينم. با 2008 كه باز كردم متوجه شدم كه كلاس ها رو خودتون تعريف كرديد
خلاصه اينكه اون كلاسها برا 2005 هم جواب داد و من الآن خيلي خوشحالم :قلب::لبخند:
مبتدي بودن اين مشكلات رو هم داره ديگه:خجالت:

soheiladv
چهارشنبه 14 خرداد 1393, 10:59 صبح
Public Class MaskedEditColumn
Inherits DataGridViewColumn
Public Sub New()
MyBase.New(New MaskedEditCell())
End Sub
Public Overrides Property CellTemplate() As DataGridViewCell
Get
Return MyBase.CellTemplate
End Get
Set(ByVal value As DataGridViewCell)

' Ensure that the cell used for the template is a CalendarCell.
If Not (value Is Nothing) AndAlso _
Not value.GetType().IsAssignableFrom(GetType(MaskedEdi tCell)) _
Then
Throw New InvalidCastException("Must be a MaskedEditCell")
End If
MyBase.CellTemplate = value
End Set
End Property
Public Property Mask() As String
Public Property ValidatingType() As Type
Private m_cPromptChar As Char = "_"c
Public Property PromptChar() As Char
Get
Return Me.m_cPromptChar
End Get
Set(ByVal value As Char)
Me.m_cPromptChar = value
End Set
End Property
End Class


Public Class MaskedEditCell
Inherits DataGridViewTextBoxCell
Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, _
ByVal initialFormattedValue As Object, _
ByVal dataGridViewCellStyle As DataGridViewCellStyle)
' Set the value of the editing control to the current cell value.
MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, _
dataGridViewCellStyle)
Dim mecol As MaskedEditColumn = DirectCast(Me.OwningColumn, MaskedEditColumn)
Dim ctl As MaskedEditingControl = _
CType(Me.DataGridView.EditingControl, MaskedEditingControl)
Try
ctl.Text = Me.Value.ToString
Catch
ctl.Text = ""
End Try
ctl.Mask = mecol.Mask
ctl.PromptChar = mecol.PromptChar
ctl.ValidatingType = mecol.ValidatingType
End Sub
Public Overrides ReadOnly Property EditType() As Type
Get
' Return the type of the editing contol that CalendarCell uses.
Return GetType(MaskedEditingControl)
End Get
End Property
Public Overrides ReadOnly Property ValueType() As Type
Get
' Return the type of the value that CalendarCell contains.
Return GetType(String)
End Get
End Property
Public Overrides ReadOnly Property DefaultNewRowValue() As Object
Get
' Use the current date and time as the default value.
Return ""
End Get
End Property
End Class


Class MaskedEditingControl
Inherits MaskedTextBox
Implements IDataGridViewEditingControl
Private dataGridViewControl As DataGridView
Private valueIsChanged As Boolean = False
Private rowIndexNum As Integer
Public Property EditingControlFormattedValue() As Object _
Implements IDataGridViewEditingControl.EditingControlFormatte dValue
Get
Return Me.Text
End Get
Set(ByVal value As Object)
Me.Text = value.ToString
End Set
End Property
Public Function EditingControlWantsInputKey(ByVal key As Keys, _
ByVal dataGridViewWantsInputKey As Boolean) As Boolean _
Implements IDataGridViewEditingControl.EditingControlWantsInp utKey
Return True
End Function
Public Function GetEditingControlFormattedValue(ByVal context _
As DataGridViewDataErrorContexts) As Object _
Implements IDataGridViewEditingControl.GetEditingControlForma ttedValue
Return Me.Text
End Function
Public Sub ApplyCellStyleToEditingControl(ByVal dataGridViewCellStyle As _
DataGridViewCellStyle) _
Implements IDataGridViewEditingControl.ApplyCellStyleToEditin gControl

Me.Font = dataGridViewCellStyle.Font
Me.ForeColor = dataGridViewCellStyle.ForeColor
Me.BackColor = dataGridViewCellStyle.BackColor
End Sub
Public Property EditingControlRowIndex() As Integer _
Implements IDataGridViewEditingControl.EditingControlRowIndex
Get
Return Me.rowIndexNum
End Get
Set(ByVal value As Integer)
Me.rowIndexNum = value
End Set
End Property
Public Sub PrepareEditingControlForEdit(ByVal selectAll As Boolean) _
Implements IDataGridViewEditingControl.PrepareEditingControlF orEdit
' No preparation needs to be done.
End Sub
Public ReadOnly Property RepositionEditingControlOnValueChange() _
As Boolean Implements _
IDataGridViewEditingControl.RepositionEditingContr olOnValueChange
Get
Return False
End Get
End Property
Public Property EditingControlDataGridView() As DataGridView _
Implements IDataGridViewEditingControl.EditingControlDataGrid View
Get
Return Me.dataGridViewControl
End Get
Set(ByVal value As DataGridView)
Me.dataGridViewControl = value
End Set
End Property

Public Property EditingControlValueChanged() As Boolean _
Implements IDataGridViewEditingControl.EditingControlValueCha nged
Get
Return Me.valueIsChanged
End Get
Set(ByVal value As Boolean)
Me.valueIsChanged = value
End Set
End Property
Public ReadOnly Property EditingControlCursor() As Cursor _
Implements IDataGridViewEditingControl.EditingPanelCursor
Get
Return MyBase.Cursor
End Get
End Property
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
' Notify the DataGridView that the contents of the cell have changed.
Me.valueIsChanged = True
Me.EditingControlDataGridView.NotifyCurrentCellDir ty(True)
MyBase.OnTextChanged(e)
End Sub
End Class