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

📄 frmselecthuajia.vb

📁 用VB.net做的关于医院收费管理系统的东西
💻 VB
字号:
Public Class frmSelectHuaJia
    Inherits System.Windows.Forms.Form
    Private gridMouseDownTime As DateTime
    Private dtList As DataTable
#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents dgdList As System.Windows.Forms.DataGrid
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmSelectHuaJia))
        Me.dgdList = New System.Windows.Forms.DataGrid
        CType(Me.dgdList, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'dgdList
        '
        Me.dgdList.CaptionVisible = False
        Me.dgdList.DataMember = ""
        Me.dgdList.Dock = System.Windows.Forms.DockStyle.Fill
        Me.dgdList.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgdList.Location = New System.Drawing.Point(0, 0)
        Me.dgdList.Name = "dgdList"
        Me.dgdList.Size = New System.Drawing.Size(472, 181)
        Me.dgdList.TabIndex = 0
        '
        'frmSelectHuaJia
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(472, 181)
        Me.Controls.Add(Me.dgdList)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "frmSelectHuaJia"
        Me.Text = "frmSelectHuaJia"
        CType(Me.dgdList, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub SetDataGrid()
        Dim db As DataBase = New DataBase
        dtList = db.RunSelectSQL("select * from 门诊挂号 where 是否已划价='否'").Table()
        db.Dispose()
        '定义一个DataGrid表样式
        Dim ts As New DataGridTableStyle
        Dim aColumnTextColumn As DataGridTextBoxColumn
        Dim numCols As Integer = dtList.Columns.Count
        Dim i As Integer
        For i = 0 To numCols - 1
            aColumnTextColumn = New DataGridTextBoxColumn
            aColumnTextColumn.MappingName = _
            dtList.Columns(i).ColumnName
            aColumnTextColumn.HeaderText = _
            dtList.Columns(i).ColumnName
            aColumnTextColumn.NullText = ""
            If i = 1 Then
                aColumnTextColumn.Width = 0
            End If
            '为列样式对应的TextBox添加事件响应
            '为DataGrid单元格支持双击双击添加事件响应
            AddHandler aColumnTextColumn.TextBox.MouseDown, _
                 New MouseEventHandler(AddressOf DGDoubleClick)
            AddHandler aColumnTextColumn.TextBox.DoubleClick, _
            New EventHandler(AddressOf dgdList_DoubleClick)
            aColumnTextColumn.ReadOnly = True
            ts.GridColumnStyles.Add(aColumnTextColumn)
        Next
        ts.AlternatingBackColor = Color.LightGray
        ts.AllowSorting = False
        ts.MappingName = dtList.TableName
        dgdList.TableStyles.Clear()
        dgdList.TableStyles.Add(ts)
        Dim dv As DataView = dtList.DefaultView
        dv.AllowNew = False
        dv.AllowDelete = False
        dv.AllowEdit = False
        '设置数据源
        dgdList.DataSource = dtList.DefaultView

    End Sub
    Private Sub frmSelectHuaJia_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SetDataGrid()
    End Sub
    Private Sub DGDoubleClick(ByVal sender As Object, ByVal e As MouseEventArgs)
        '判断两次单击时间是否小于双击的时间间隔
        If (DateTime.Now < gridMouseDownTime.AddMilliseconds(SystemInformation.DoubleClickTime)) Then
            '两次单击时间小于双击的时间间隔则调用dgdGoodInfo双击处理函数
            Me.dgdList_DoubleClick(Nothing, Nothing)
        End If
    End Sub
    Private Sub dgdList_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgdList.DoubleClick
        'Dim iRow As Integer = dgdList.CurrentRowIndex
        'Dim sId As String
        ''获取DataGrid当前被选中的行的内容
        'sId = dtList.Rows(iRow)("编号").ToString()
        'MessageBox.Show(sId)
        Me.Close()
    End Sub
    Private Sub dgdList_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgdList.MouseDown
        '记住在dgdGoodInfo点下鼠标的时间
        gridMouseDownTime = DateTime.Now
    End Sub
    Public Function GetInfo() As String
        '获得DataGrid当前被选中的行号
        Dim iRow As Integer = dgdList.CurrentRowIndex
        Dim sId As String
        '获取DataGrid当前被选中的行的内容
        sId = dtList.Rows(iRow)("编号").ToString()
        'MessageBox.Show(sId)
        Return sId
    End Function

    Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        If msg.WParam.ToInt32() = CInt(Keys.Enter) Then
            Me.Close()
            Return True
        End If
        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function
End Class

⌨️ 快捷键说明

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