'回车键,跳格,并选中内容。
Private Sub FrmFiber_KeyPress(ByVal sender As System.Object,ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
If e.KeyChar = ChrW(Keys.Enter) ThenMe.SelectNextControl(Me.ActiveControl,True,False,True)
If TypeOf Me.ActiveControl Is TextBox Then
Dim ctlTextBox As TextBox = CType(Me.ActiveControl,TextBox)
If String.IsNullOrEmpty(ctlTextBox.Text) = False Then
ctlTextBox.SelectAll()
End If
End If
End If
End Sub
'对两个Datatable的结构相同进行合并:
Dim db As Datatable = Nothing
Dim dt As DataTable = ds.Tables(0)
'''/两个datatable进行合并
db = dt.Copy()
Dim foundRows As DataRow() = dt.Select()
For i As Integer = 0 To foundRows.Length - 1
db.ImportRow(foundRows(i))
Next
'两个结构一样的DT合并
Dim DataTable1 As New DataTable()
Dim DataTable2 As New DataTable()
Dim newDataTable As DataTable = DataTable1.Clone()
Dim obj As Object() = New Object(newDataTable.Columns.Count - 1) {}
For i As Integer = 0 To DataTable1.Rows.Count - 1
DataTable1.Rows(i).ItemArray.CopyTo(obj,0)
newDataTable.Rows.Add(obj)
Next
For i As Integer = 0 To DataTable2.Rows.Count - 1
DataTable2.Rows(i).ItemArray.CopyTo(obj,0)
newDataTable.Rows.Add(obj)
Next
Private Sub BtnExeQuery_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles BtnExeQuery.Click
Dim cd As String
Dim cmd As New sqlClient.sqlCommand
Dim strWhere As String = String.Empty
cd = " and "
If String.IsNullOrEmpty(Me.TxtLotNo.Text.Trim) = False Then
strWhere &= (IIf(String.IsNullOrEmpty(strWhere),"",cd) & "strLotNo like (@strLotNo)")
cmd.Parameters.Add(New sqlClient.sqlParameter("@strLotNo",Me.TxtLotNo.Text.Trim & "%"))
End If
If String.IsNullOrEmpty(Me.TxtColorNo.Text.Trim) = False Then
strWhere &= (IIf(String.IsNullOrEmpty(strWhere),cd) & "strItemName like (@strItemName)")
cmd.Parameters.Add(New sqlClient.sqlParameter("@strItemName",Me.TxtColorNo.Text.Trim & "%"))
End If
If String.IsNullOrEmpty(Me.TxtPly.Text.Trim) = False Then
strWhere &= (IIf(String.IsNullOrEmpty(strWhere),cd) & "lngPly = (@lngPly)")
cmd.Parameters.Add(New sqlClient.sqlParameter("@lngPly",CInt(Me.TxtPly.Text.Trim)))
End If
If String.IsNullOrEmpty(Me.TxtYarnCount.Text.Trim) = False Then
strWhere &= (IIf(String.IsNullOrEmpty(strWhere),cd) & "dblYarnCount = (@dblYarnCount)")
cmd.Parameters.Add(New sqlClient.sqlParameter("@dblYarnCount",CDbl(Me.TxtYarnCount.Text.Trim)))
End If
If String.IsNullOrEmpty(Me.TxtMoistureRegain.Text.Trim) = False Then
strWhere &= (IIf(String.IsNullOrEmpty(strWhere),cd) & "dblMoistureRegain = (@dblMoistureRegain)")
cmd.Parameters.Add(New sqlClient.sqlParameter("@dblMoistureRegain",CDbl(Me.TxtMoistureRegain.Text.Trim)))
End If
If Me.CboWarehouseID.SelectedIndex > -1 Then
strWhere &= (IIf(String.IsNullOrEmpty(strWhere),cd) & "intWarehouseID = (@intWarehouseID)")
cmd.Parameters.Add(New sqlClient.sqlParameter("@intWarehouseID",CInt(Me.CboWarehouseID.SelectedValue)))
End If
If Me.ChkDeliveryDate.Checked Then
strWhere &= (IIf(String.IsNullOrEmpty(strWhere),cd) & "dtmDelivery = (@dtmDelivery)")
cmd.Parameters.Add(New sqlClient.sqlParameter("@dtmDelivery",Me.dtmDeliveryDate.Value.Date))
End If
cmd.CommandText = "select " & strLotFields & " from tblLot where strStatus<>'Void' and " & IIf(String.IsNullOrEmpty(strWhere),"1=1",strWhere)
'cmd.CommandText ="sp_QueryItem"
'cmd.CommandType = CommandType.StoredProcedure
tblQuery = sqlHelper.GetDataTable(cmd)
BindDv(tblQuery)
End Sub
Imports System.Drawing Public Class UserControl1 Private Sub UserControl1_MouseHover(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.MouseHover Using g As Graphics = Graphics.FromHwnd(Me.Handle) g.DrawRectangle(Pens.Blue,Me.Width - 1,Me.Height - 1) End Using End Sub Private Sub UserControl1_MouseLeave(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.MouseLeave Using g As Graphics = Graphics.FromHwnd(Me.Handle) g.DrawRectangle(New Pen(Me.BackColor),Me.Height - 1) End Using End Sub End Class原文链接:https://www.f2er.com/vb/260692.html