I m trying to use "C1TrueDBGrid control for .NET Windows Forms (VS 2002)" along with DataGridComboBoxColumn class
I have imported the DataGridComboBoxColumn.vb to my project
Here is the code of DataGridComboBoxColumn.vb :
Public Class DataGridComboBoxColumn
#Region " Declarations "
Inherits DataGridTextBoxColumn
Public ColumnComboBox As NoKeyUpCombo
Private mcmSource As System.Windows.Forms.CurrencyManager
Private mintRowNum As Integer
Private mblnEditing As Boolean
#End Region
#Region " Constructor "
Public Sub New()
mcmSource = Nothing
mblnEditing = False
ColumnComboBox = New NoKeyUpCombo
ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDownList
AddHandler ColumnComboBox.Leave, AddressOf LeaveComboBox
AddHandler ColumnComboBox.SelectionChangeCommitted, AddressOf ComboStartEditing
End Sub
#End Region
#Region " Private Methods "
Private Sub HandleScroll(ByVal sender As Object, ByVal e As EventArgs)
If ColumnComboBox.Visible Then ColumnComboBox.Hide()
End Sub
Private Sub ComboStartEditing(ByVal sender As Object, ByVal e As EventArgs)
mblnEditing = True
MyBase.ColumnStartedEditing(sender)
End Sub
Private Sub LeaveComboBox(ByVal sender As Object, ByVal e As EventArgs)
If mblnEditing Then
SetColumnValueAtRow(mcmSource, mintRowNum, ColumnComboBox.Text)
mblnEditing = False
Invalidate()
End If
ColumnComboBox.Hide()
AddHandler Me.DataGridTableStyle.DataGrid.Scroll, New EventHandler(AddressOf HandleScroll)
End Sub
#End Region
#Region " Overridden Methods "
Protected Overloads Overrides Sub Edit( _
ByVal [source] As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As System.Drawing.Rectangle, _
ByVal [readOnly] As Boolean, _
ByVal instantText As String, _
ByVal cellIsVisible As Boolean)
MyBase.Edit([source], rowNum, bounds, [readOnly], instantText, cellIsVisible)
mintRowNum = rowNum
mcmSource = [source]
With ColumnComboBox
.Parent = Me.TextBox.Parent
.Location = Me.TextBox.Location
.Size = New Size(Me.TextBox.Size.Width, .Size.Height)
.SelectedIndex = .FindStringExact(Me.TextBox.Text)
.Text = Me.TextBox.Text
Me.TextBox.Visible = False
.Visible = True
AddHandler Me.DataGridTableStyle.DataGrid.Scroll, AddressOf HandleScroll
.BringToFront()
.Focus()
End With
End Sub
Protected Overrides Function Commit( _
ByVal dataSource As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer) As Boolean
If mblnEditing Then
mblnEditing = False
SetColumnValueAtRow(dataSource, rowNum, ColumnComboBox.Text)
End If
Return True
End Function
Protected Overrides Sub ConcedeFocus()
Console.WriteLine("ConcedeFocus")
MyBase.ConcedeFocus()
End Sub
Protected Overrides Function GetColumnValueAtRow( _
ByVal [source] As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer) As Object
Dim s As Object = MyBase.GetColumnValueAtRow([source], rowNum)
Dim dv As DataView = CType(Me.ColumnComboBox.DataSource, DataView)
Dim rowCount As Integer = dv.Count
Dim i As Integer = 0
Dim obj As Object
While i < rowCount
obj = dv(i)(Me.ColumnComboBox.ValueMember)
If (Not obj Is DBNull.Value) AndAlso _
(Not s Is DBNull.Value) AndAlso _
(s = obj) Then
Exit While
End If
i += 1
End While
If i < rowCount Then
Return dv(i)(Me.ColumnComboBox.DisplayMember)
End If
Return DBNull.Value
End Function
Protected Overrides Sub SetColumnValueAtRow( _
ByVal [source] As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer, ByVal value As Object)
Dim s As Object = value
Dim dv As DataView = CType(Me.ColumnComboBox.DataSource, DataView)
Dim rowCount As Integer = dv.Count
Dim i As Integer = 0
Dim obj As Object
While i < rowCount
obj = dv(i)(Me.ColumnComboBox.DisplayMember)
If (Not obj Is DBNull.Value) AndAlso _
(s = obj) Then
Exit While
End If
i += 1
End While
If i < rowCount Then
s = dv(i)(Me.ColumnComboBox.ValueMember)
Else
s = DBNull.Value
End If
MyBase.SetColumnValueAtRow([source], rowNum, s)
End Sub
#End Region
End Class
---------------------------------------------------------
When i m trying to build my project i get an error :
'Win' is not a member of 'System.Windows.Forms.DataGridTextBoxColumn'.
This points to
Me.C1TrueDBGrid1.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder
in the #Region of my main form
what seems to be the problem?
Thank you
I have imported the DataGridComboBoxColumn.vb to my project
Here is the code of DataGridComboBoxColumn.vb :
Public Class DataGridComboBoxColumn
#Region " Declarations "
Inherits DataGridTextBoxColumn
Public ColumnComboBox As NoKeyUpCombo
Private mcmSource As System.Windows.Forms.CurrencyManager
Private mintRowNum As Integer
Private mblnEditing As Boolean
#End Region
#Region " Constructor "
Public Sub New()
mcmSource = Nothing
mblnEditing = False
ColumnComboBox = New NoKeyUpCombo
ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDownList
AddHandler ColumnComboBox.Leave, AddressOf LeaveComboBox
AddHandler ColumnComboBox.SelectionChangeCommitted, AddressOf ComboStartEditing
End Sub
#End Region
#Region " Private Methods "
Private Sub HandleScroll(ByVal sender As Object, ByVal e As EventArgs)
If ColumnComboBox.Visible Then ColumnComboBox.Hide()
End Sub
Private Sub ComboStartEditing(ByVal sender As Object, ByVal e As EventArgs)
mblnEditing = True
MyBase.ColumnStartedEditing(sender)
End Sub
Private Sub LeaveComboBox(ByVal sender As Object, ByVal e As EventArgs)
If mblnEditing Then
SetColumnValueAtRow(mcmSource, mintRowNum, ColumnComboBox.Text)
mblnEditing = False
Invalidate()
End If
ColumnComboBox.Hide()
AddHandler Me.DataGridTableStyle.DataGrid.Scroll, New EventHandler(AddressOf HandleScroll)
End Sub
#End Region
#Region " Overridden Methods "
Protected Overloads Overrides Sub Edit( _
ByVal [source] As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As System.Drawing.Rectangle, _
ByVal [readOnly] As Boolean, _
ByVal instantText As String, _
ByVal cellIsVisible As Boolean)
MyBase.Edit([source], rowNum, bounds, [readOnly], instantText, cellIsVisible)
mintRowNum = rowNum
mcmSource = [source]
With ColumnComboBox
.Parent = Me.TextBox.Parent
.Location = Me.TextBox.Location
.Size = New Size(Me.TextBox.Size.Width, .Size.Height)
.SelectedIndex = .FindStringExact(Me.TextBox.Text)
.Text = Me.TextBox.Text
Me.TextBox.Visible = False
.Visible = True
AddHandler Me.DataGridTableStyle.DataGrid.Scroll, AddressOf HandleScroll
.BringToFront()
.Focus()
End With
End Sub
Protected Overrides Function Commit( _
ByVal dataSource As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer) As Boolean
If mblnEditing Then
mblnEditing = False
SetColumnValueAtRow(dataSource, rowNum, ColumnComboBox.Text)
End If
Return True
End Function
Protected Overrides Sub ConcedeFocus()
Console.WriteLine("ConcedeFocus")
MyBase.ConcedeFocus()
End Sub
Protected Overrides Function GetColumnValueAtRow( _
ByVal [source] As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer) As Object
Dim s As Object = MyBase.GetColumnValueAtRow([source], rowNum)
Dim dv As DataView = CType(Me.ColumnComboBox.DataSource, DataView)
Dim rowCount As Integer = dv.Count
Dim i As Integer = 0
Dim obj As Object
While i < rowCount
obj = dv(i)(Me.ColumnComboBox.ValueMember)
If (Not obj Is DBNull.Value) AndAlso _
(Not s Is DBNull.Value) AndAlso _
(s = obj) Then
Exit While
End If
i += 1
End While
If i < rowCount Then
Return dv(i)(Me.ColumnComboBox.DisplayMember)
End If
Return DBNull.Value
End Function
Protected Overrides Sub SetColumnValueAtRow( _
ByVal [source] As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer, ByVal value As Object)
Dim s As Object = value
Dim dv As DataView = CType(Me.ColumnComboBox.DataSource, DataView)
Dim rowCount As Integer = dv.Count
Dim i As Integer = 0
Dim obj As Object
While i < rowCount
obj = dv(i)(Me.ColumnComboBox.DisplayMember)
If (Not obj Is DBNull.Value) AndAlso _
(s = obj) Then
Exit While
End If
i += 1
End While
If i < rowCount Then
s = dv(i)(Me.ColumnComboBox.ValueMember)
Else
s = DBNull.Value
End If
MyBase.SetColumnValueAtRow([source], rowNum, s)
End Sub
#End Region
End Class
---------------------------------------------------------
When i m trying to build my project i get an error :
'Win' is not a member of 'System.Windows.Forms.DataGridTextBoxColumn'.
This points to
Me.C1TrueDBGrid1.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder
in the #Region of my main form
what seems to be the problem?
Thank you