frmQuery.vb
上传用户:wj57717022
上传日期:2014-12-16
资源大小:4093k
文件大小:6k
- Imports localJxc.jxcmanage
- Public Class frmQuery
- Inherits System.Windows.Forms.Form
- #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 dgquery As System.Windows.Forms.DataGrid
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.dgquery = New System.Windows.Forms.DataGrid
- CType(Me.dgquery, System.ComponentModel.ISupportInitialize).BeginInit()
- Me.SuspendLayout()
- '
- 'dgquery
- '
- Me.dgquery.AlternatingBackColor = System.Drawing.Color.Gainsboro
- Me.dgquery.BackColor = System.Drawing.Color.Silver
- Me.dgquery.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
- Me.dgquery.CaptionBackColor = System.Drawing.Color.DarkSlateBlue
- Me.dgquery.CaptionFont = New System.Drawing.Font("Tahoma", 8.0!)
- Me.dgquery.CaptionForeColor = System.Drawing.Color.White
- Me.dgquery.CaptionVisible = False
- Me.dgquery.DataMember = ""
- Me.dgquery.Dock = System.Windows.Forms.DockStyle.Fill
- Me.dgquery.FlatMode = True
- Me.dgquery.ForeColor = System.Drawing.Color.Black
- Me.dgquery.GridLineColor = System.Drawing.Color.White
- Me.dgquery.HeaderBackColor = System.Drawing.Color.DarkGray
- Me.dgquery.HeaderForeColor = System.Drawing.Color.Black
- Me.dgquery.LinkColor = System.Drawing.Color.DarkSlateBlue
- Me.dgquery.Location = New System.Drawing.Point(0, 0)
- Me.dgquery.Name = "dgquery"
- Me.dgquery.ParentRowsBackColor = System.Drawing.Color.Black
- Me.dgquery.ParentRowsForeColor = System.Drawing.Color.White
- Me.dgquery.RowHeadersVisible = False
- Me.dgquery.SelectionBackColor = System.Drawing.Color.DarkSlateBlue
- Me.dgquery.SelectionForeColor = System.Drawing.Color.White
- Me.dgquery.Size = New System.Drawing.Size(488, 317)
- Me.dgquery.TabIndex = 0
- '
- 'frmQuery
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
- Me.ClientSize = New System.Drawing.Size(488, 317)
- Me.ControlBox = False
- Me.Controls.Add(Me.dgquery)
- Me.Name = "frmQuery"
- Me.Text = "客户信息"
- CType(Me.dgquery, System.ComponentModel.ISupportInitialize).EndInit()
- Me.ResumeLayout(False)
- End Sub
- #End Region
- Public PYM As String
- Public weblocal As New jxcmanage
- Public dtlist As DataTable
- Private Sub frmQuery_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- SetDataGrid(weblocal.QueryID(PYM, "sp_querykhId"), dgquery)
-
- End Sub
- '重新设置datagrid
- Public Sub SetDataGrid(ByVal mSpDataset As Data.DataSet, ByVal dgDatagrid As DataGrid)
- Dim dtCustomerId As Data.DataSet
- dtCustomerId = mSpDataset
- Dim dts As DataTable = mSpDataset.Tables(0)
- 'bb为一随意表名
- dts.TableName = "bb"
- dtlist = dts
- Dim tss As New DataGridTableStyle 'datagrid样式
- Dim aColumnTextColumns As DataGridTextBoxColumn
- dgDatagrid.DataSource = dts
- tss.MappingName = dts.TableName
- Dim numColss As Integer
- numColss = dts.Columns.Count
- Dim i As Integer = 0
- Do While (i < numColss) '重绘所有的列
- aColumnTextColumns = New DataGridTextBoxColumn
- '夺过对textbox内落下光标的控制权
- AddHandler aColumnTextColumns.TextBox.Enter, New EventHandler(AddressOf TextBoxEnterHandler)
- '要更改列头名,请改下句的HeaderText值
- aColumnTextColumns.HeaderText = dts.Columns(i).ColumnName
- aColumnTextColumns.MappingName = dts.Columns(i).ColumnName
- tss.GridColumnStyles.Add(aColumnTextColumns) '增加一种自定义的column风格
- i = (i + 1)
- Loop
- dgDatagrid.TableStyles.Clear()
- dgDatagrid.TableStyles.Add(tss) '增加一种自定义的表风格
- End Sub
- Private Sub TextBoxEnterHandler(ByVal sender As Object, ByVal e As System.EventArgs)
- Dim inner As Control = sender
- inner.Visible = False
- dgquery.Select(dgquery.CurrentRowIndex)
- End Sub
- Public Function GetInfo(ByVal strnumber As String) As String
- '获得DataGrid当前被选中的行号
- Dim iRow As Integer = dgquery.CurrentRowIndex
- Dim sId As String
- '获取DataGrid当前被选中的行的内容
- Try
- sId = dtlist.Rows(iRow)(strnumber).ToString().Trim
- Return sId
- Catch ex As Exception
- 'MessageBox.Show("没有查到您所要的记录,请重新查找!")
- End Try
- 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
- dgquery.UnSelect(dgquery.CurrentRowIndex)
- Me.Close()
- Return True
- End If
- Return MyBase.ProcessCmdKey(msg, keyData)
- End Function
- Private Sub dgquery_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles dgquery.Navigate
- End Sub
- End Class