Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27329

VS 2010 Convert from DataGridTextBoxColumn to DataGridViewTextBoxColumn

$
0
0
Hi

I have a DataGridTextBoxColumn user control:
Code:

Public Class DataGridTextDescriptionColumn

    Inherits DataGridTextBoxColumn
    'Dim strConnection = ("Provider=MSDAORA.1;Password=app123;User ID=app;Data Source=work")
    'Dim strConnection = AppSettings.Get("Oracle_DB")
    'Dim clsDBORA As New clsDBORA
    Dim gChldFrm As New Object
    Dim iCol As Integer
    Dim alignToRight As Boolean

    Public Sub New(ByVal fFrmName As Object, ByVal iColumn As Integer, _
    Optional ByVal blnMirrored As Boolean = False)
        ' Initialise the object and set its default properities
        MyBase.New()
        gChldFrm = fFrmName
        iCol = iColumn
        Me.NullText = ""
        Me.ReadOnly = True
        If blnMirrored = True Then
            Me.alignToRight = True
        Else
            Me.alignToRight = False
        End If
    End Sub

    Protected Overloads Overrides Sub Edit(ByVal source As CurrencyManager, _
    ByVal rowNum As Integer, ByVal bounds As Rectangle, ByVal readOnly1 As Boolean, _
    ByVal instantText As String, ByVal cellIsVisible As Boolean)
        ' This particular column will always be readonly and non-editable - therefore do not pass the event over
        Return
    End Sub

    Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics, _
    ByVal bounds As System.Drawing.Rectangle, _
    ByVal [source] As System.Windows.Forms.CurrencyManager, _
    ByVal rowNum As Integer, ByVal backBrush As System.Drawing.Brush, _
    ByVal foreBrush As System.Drawing.Brush, ByVal alignToRight As Boolean)
        g.FillRectangle(New SolidBrush(Color.White), bounds)
        Dim parent As DataGrid = Me.DataGridTableStyle.DataGrid
        Dim s As String = DirectCast(gChldFrm,  _
        ICommandGetDesc).cmdGetDesc(parent, parent(rowNum, iCol).ToString(), rowNum, _
        iCol)
        Dim font As New Font("Arial", 8.25F)
        If alignToRight Then
            ' Right align using MeasureString to determine the size of the string
            Dim cellDimensions As SizeF = g.MeasureString(s, font, New SizeF(bounds.Width, _
            bounds.Height), StringFormat.GenericDefault)
            g.DrawString(s, font, New SolidBrush(Color.Black), bounds.Right - _
            cellDimensions.Width, bounds.Y)
        Else
            ' Left alignment
            g.DrawString(s, font, New SolidBrush(Color.Black), bounds.X, bounds.Y)
        End If

        '        g.DrawString(s, font, New SolidBrush(Color.Black), bounds.X, bounds.Y)
        font.Dispose()
    End Sub

    Protected Overrides Sub Abort(ByVal rowNum As Integer)

    End Sub

    Protected Overrides Function Commit(ByVal dataSource As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Boolean

    End Function

    Protected Overrides Function GetMinimumHeight() As Integer

    End Function

    Protected Overrides Function GetPreferredHeight(ByVal g As System.Drawing.Graphics, ByVal value As Object) As Integer

    End Function

    Protected Overrides Function GetPreferredSize(ByVal g As System.Drawing.Graphics, ByVal value As Object) As System.Drawing.Size

    End Function
End Class

How can I convert it to DataGridViewTextBoxColumn?

Viewing all articles
Browse latest Browse all 27329

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>