Common: Add Control helper
This commit is contained in:
parent
960c7ecb27
commit
01767669c9
66
GUIs.Common/ControlHelper.vb
Normal file
66
GUIs.Common/ControlHelper.vb
Normal file
@ -0,0 +1,66 @@
|
||||
Imports System.Windows.Forms
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class ControlHelper
|
||||
Inherits BaseClass
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function HasValue(pControl As Control) As Boolean
|
||||
Return Utils.NotNull(GetValue(pControl), Nothing) IsNot Nothing
|
||||
End Function
|
||||
|
||||
Public Function GetValue(pControl As Control) As Object
|
||||
Dim oControlValue As Object
|
||||
|
||||
Select Case pControl.GetType
|
||||
Case GetType(TextBox)
|
||||
oControlValue = pControl.Text
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.TextEdit)
|
||||
Dim oTextEdit As DevExpress.XtraEditors.TextEdit = pControl
|
||||
oControlValue = oTextEdit.EditValue
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.DateEdit)
|
||||
Dim oDateEdit As DevExpress.XtraEditors.DateEdit = pControl
|
||||
oControlValue = oDateEdit.EditValue
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.LookUpEdit)
|
||||
Dim oLookupEdit As DevExpress.XtraEditors.LookUpEdit = pControl
|
||||
oControlValue = oLookupEdit.EditValue
|
||||
|
||||
Case GetType(Controls.LookupGrid.LookupControl3)
|
||||
Dim oLookupControl3 As Controls.LookupGrid.LookupControl3 = pControl
|
||||
If oLookupControl3.Properties.SelectedValues.Count = 1 Then
|
||||
oControlValue = oLookupControl3.Properties.SelectedValues.Item(0)
|
||||
Else
|
||||
oControlValue = "0"
|
||||
End If
|
||||
|
||||
Case GetType(ComboBox)
|
||||
oControlValue = pControl.Text
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.ComboBoxEdit)
|
||||
Dim oCombobox As DevExpress.XtraEditors.ComboBoxEdit = pControl
|
||||
oControlValue = oCombobox.EditValue
|
||||
|
||||
Case GetType(CheckBox)
|
||||
Dim oCheckBox As CheckBox = pControl
|
||||
oControlValue = oCheckBox.Checked
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.CheckEdit)
|
||||
Dim oCheckEdit As DevExpress.XtraEditors.CheckEdit = pControl
|
||||
oControlValue = oCheckEdit.Checked
|
||||
|
||||
Case Else
|
||||
oControlValue = "0"
|
||||
|
||||
End Select
|
||||
|
||||
Return oControlValue
|
||||
End Function
|
||||
End Class
|
||||
Loading…
x
Reference in New Issue
Block a user