⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datagridprioritycolumn.vb

📁 TaskVision 应用程序展示了用于个人和公司相关任务管理的一个完整的 n 层应用程序。该示例附带了用于运行某个私有任务服务器应用程序的随时可运行的示范客户端、全部客户端源代码
💻 VB
字号:
Imports System.IO

Public Class DataGridPriorityColumn
    Inherits System.Windows.Forms.DataGridTextBoxColumn

    Private m_HtImages As New Hashtable()
    Private Const c_PriorityImagesPath As String = "Images\"
    Private m_ResourceManager As New Resources.ResourceManager("TaskVision.Localize", System.Reflection.Assembly.GetExecutingAssembly())

    Public Sub New(ByVal headerText As String, ByVal mappingName As String, ByVal width As Integer)
        MyBase.HeaderText = headerText
        MyBase.MappingName = mappingName
        MyBase.Width = width
    End Sub

    Protected Overloads Overrides Sub Edit(ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal bounds As System.Drawing.Rectangle, ByVal isReadOnly As Boolean, ByVal instantText As String, ByVal cellIsVisible As Boolean)
        'do nothing
    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)
        Dim bVal As Object = GetColumnValueAtRow(source, rowNum)

        Dim imageToDraw As Image

        'we're caching the image in a hashtable
        If m_HtImages.ContainsKey(bVal) Then
            imageToDraw = CType(m_HtImages(bVal), System.Drawing.Image)
        Else
            'get the image from disk and cache it
            Try
                imageToDraw = Image.FromFile(c_PriorityImagesPath & CType(bVal, String) & ".gif")
                m_HtImages.Add(bVal, imageToDraw)
            Catch
                MessageBox.Show(m_ResourceManager.GetString("The_image_file") & " " & Application.StartupPath & "\" & c_PriorityImagesPath & CType(bVal, String) & m_ResourceManager.GetString("gif_was_not_found"), m_ResourceManager.GetString("File_Not_Found"))
                LogError.Write(m_ResourceManager.GetString("The_image_file") & " " & Application.StartupPath & "\" & c_PriorityImagesPath & CType(bVal, String) & m_ResourceManager.GetString("gif_was_not_found"))
                Return
            End Try
        End If


        'if the current row is this row, draw the selection back color
        If Me.DataGridTableStyle.DataGrid.CurrentRowIndex = rowNum Then
            g.FillRectangle(New SolidBrush(Me.DataGridTableStyle.SelectionBackColor), bounds)
        Else
            g.FillRectangle(backBrush, bounds)
        End If

        g.DrawImage(imageToDraw, New Point(bounds.X, bounds.Y))
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -