自己用兩個COMBO寫一個不就行了嗎
在焦作等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站設(shè)計(jì)制作、網(wǎng)站設(shè)計(jì) 網(wǎng)站設(shè)計(jì)制作定制制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),成都營銷網(wǎng)站建設(shè),外貿(mào)營銷網(wǎng)站建設(shè),焦作網(wǎng)站建設(shè)費(fèi)用合理。
何必用控件呢
##################################
Private Sub Form_Load()
For n = 1949 To 2008
Combo1.AddItem n
Next
Combo1.ListIndex = 0
For n = 1 To 12
Combo2.AddItem n
Next
Combo2.ListIndex = 0
End Sub
‘以如下的方式獲取時(shí)間
Private Sub Command1_Click()
MsgBox "當(dāng)前選擇的是" Combo1.Text "年" Combo2.Text "月", vbInformation, "年月"
End Sub
希望對你有幫助
用crystal報(bào)表,文件——新建文件——crystal報(bào)表,然后根據(jù)向?qū)Ы?/p>
Dim tab1 As String
Dim DS As New DataSet
Dim SqlStr As String
Dim DTS_A As New DataGridTableStyle
Dim Col_A1, Col_A2, Col_A3 As New DataGridTextBoxColumn
Dim Col_bo As New DataGridBoolColumn
'DS.Tables("tab1").Columns.Add("check", System.Type.GetType("System.Boolean"))
'DS.Tables("tab1").Columns("check").DefaultValue = False
Dim Col_A() As DataGridColumnStyle = {Col_bo, Col_A1, Col_A2, Col_A3}
'主窗口
Private Sub fICitem_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ProgressBar1.Hide()
grdStyles("tab1")
SQLConn(conn)
Dim i As Integer
'Dim arr As New ArrayList
SqlStr = "SELECT ID, diqu, dname FROM a_diqu Order by ID"
If Not SQLFill(conn, DA, DS, SqlStr, "diqu") Then
MsgBox("服務(wù)器連接失敗")
Else
Dim dr As DataRow
For Each dr In DS.Tables("diqu").Rows
'arr.Add(dr("diqu") "." dr("dname"))
cmbDiqu.Items.Add(dr("diqu") "." dr("dname"))
Next
End If
'cmbDiqu.DataSource = arr
cmbDiqu.SelectedIndex = -1
cmbDiqu.Text = ""
End Sub
'DataGrid格式
Private Sub grdStyles(ByVal tab As String)
Dim ii1 As Integer
Dim DTS_A1() As String = {"check", "fshortnumber", "fnumber", "fplanprice"}
Dim DTS_A2() As String = {"檢查框", "貨號", "上市月份", "單價(jià)"}
Dim DTS_A3() As Integer = {50, 120, 120, 120} '長度
Dim DTS_A4() As Integer = {2, 0, 2, 1} '對齊方式
DTS_A.MappingName = tab
DTS_A.GridColumnStyles.Clear()
DTS_A.AllowSorting = True
DTS_A.ReadOnly = True
DTS_A.BackColor = Color.DarkGray
DTS_A.AlternatingBackColor = Color.LightGray
For ii1 = 0 To DTS_A1.Length - 1
Col_A(ii1).MappingName = DTS_A1(ii1)
Col_A(ii1).HeaderText = DTS_A2(ii1)
Col_A(ii1).Width = DTS_A3(ii1)
Col_A(ii1).NullText = ""
Col_A(ii1).Alignment = DTS_A4(ii1)
Next
DTS_A.GridColumnStyles.AddRange(Col_A)
grdItem.TableStyles.Add(DTS_A)
grdItem.ReadOnly = True
End Sub
Private Sub fICitem_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
SQLClose(conn)
End Sub
'顯示表單
Private Sub Show1()
grdStyles("tab1")
txtNum.Text = Trim(txtNum.Text)
grdItem.DataSource = Nothing
SQLStr = "select * from t_icitem_new"
SQLStr = " where fshortnumber like '" txtNum.Text "%'"
SQLStr = " order by fshortnumber"
SQLFill(conn, DA, DS, SQLStr, tab1)
grdItem.CaptionText = "貨號資料"
grdItem.DataSource = DS.Tables(tab1)
ShowRow()
End Sub
'數(shù)據(jù)同步顯示
Private Sub ShowRow()
Dim dr As DataRow
If DS.Tables(tab1).Rows.Count 0 Then
If grdItem.CurrentRowIndex DS.Tables(tab1).Rows.Count Then
grdItem.CaptionText = grdItem.CurrentRowIndex + 1 "/" DS.Tables(tab1).Rows.Count
dr = DS.Tables(tab1).Rows(grdItem.CurrentRowIndex)
txtNum.Text = dr.Item("fshortnumber")
txtPrice.Text = dr.Item("fplanprice")
cmbMonth.Text = dr.Item("fnumber")
Else
txtNum.Text = ""
txtPrice.Text = ""
cmbMonth.Text = ""
End If
Else
txtNum.Text = ""
txtPrice.Text = ""
cmbMonth.Text = ""
End If
End Sub
Private Sub grdItem_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdItem.CurrentCellChanged
ShowRow()
End Sub
'鼠標(biāo)選定行
Private Sub grdItem_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdItem.CurrentCellChanged
ShowRow()
End Sub
Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnSelect.Click, btnUpdate.Click, btnInsert.Click, btnDelete.Click
Select Case sender.name
Case "btnSelect" '查詢
Show1()
Case "btnUpdate" '修改
SUpdate()
Case "btnInsert" '新增
SInsert()
Case "btnDelete" '刪除
SDelete()
End Select
End Sub
'修改
Private Sub SUpdate()
txtNum.Text = Trim(txtNum.Text)
txtPrice.Text = Trim(txtPrice.Text)
If MsgBox("確定更新?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
SQLStr = "UPDATE t_icitem_new SET "
SQLStr = "fnumber='" cmbMonth.SelectedItem "', "
SQLStr = "fplanprice='" txtPrice.Text "' "
SQLStr = "WHERE fshortnumber='" txtNum.Text "'"
If Not SQLFill2(conn, SQLStr) Then
MsgBox("抱歉,更新失敗:(")
End If
Show1()
End If
End Sub
'新增
Private Sub SInsert()
txtNum.Text = Trim(txtNum.Text)
txtPrice.Text = Trim(txtPrice.Text)
If MsgBox("確定新增?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
SQLStr = "SELECT fshortnumber "
SQLStr = "FROM t_icitem_new "
SQLStr = "WHERE fshortnumber = '" txtNum.Text "' "
SQLFill(conn, DA, DS, SQLStr, "Tmp")
If DS.Tables("Tmp").Rows.Count = 0 Then '如果沒有資料則新增
SQLStr = "INSERT INTO t_icitem_new (fshortnumber,fnumber,fplanprice) VALUES("
SQLStr = "'" txtNum.Text "', "
SQLStr = "'" cmbMonth.SelectedItem "', "
SQLStr = "'" txtPrice.Text "')"
If Not SQLFill2(conn, SQLStr) Then
MsgBox("抱歉,新增失敗:(")
End If
Show1()
Else
MsgBox("資料已存在")
End If
End If
End Sub
'刪除
Private Sub SDelete()
txtNum.Text = Trim(txtNum.Text)
txtPrice.Text = Trim(txtPrice.Text)
If MsgBox("確定刪除" txtNum.Text "?", MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2) = MsgBoxResult.Yes Then
SQLStr = "DELETE FROM t_icitem_new "
SQLStr = "WHERE fshortnumber='" txtNum.Text "'"
If Not SQLFill2(conn, SQLStr) Then
MsgBox("抱歉,刪除失敗:(")
End If
Show1()
End If
'鍵盤順序
Private Sub txt_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles txtFshop.KeyDown, txtItem.KeyDown
Select Case e.KeyCode
Case Keys.Return
SendKeys.Send("{TAB}")
Case Keys.Right
SendKeys.Send("{TAB}")
Case Keys.Left
SendKeys.Send("+{TAB}")
Case Keys.Down
SendKeys.Send("{TAB 10}")
Case Keys.Up
SendKeys.Send("+{TAB 10}")
End Select
End Sub
VB或vb.NET或其它語言的控件都無法顯示陰歷,因?yàn)閲獠皇褂藐帤v,你只能在網(wǎng)上找找第三方控件
;?? Visual Studio NET提供的MonthCalendar控件允許你選擇日期和一組日期 這個控件允許用戶方便地選擇日期 它類似于讓你選擇一個特定日期的DataTimePicker控件 不過MonthCalendar控件還可以幫助你選擇一個時(shí)間
使用MonthCalendar 控件
下面的例子說明如何使用MonthCalendar控件
在常用控件(Common Controls)下的工具箱(Toolbox)中找到MonthCalendar控件并將它添加到窗口表單(Window Form)中 設(shè)置以下屬性
·Name mcDateSelection
·TodayDate 空
·MaxSelectionCount
·Selection Range Start 空
·Selection Range End 空
在Form Load事件中添加以下代碼
mcDateSelection TodayDate = Now
然后建立列表A中的事件 在這個例子中 我設(shè)置MaxSelectionCount屬性為 這意味著你只能在MonthCalendar控件中選擇一個 而不是一組日期 在MonthView控件中選擇一個日期 屏幕即類似于圖A
圖A
列表A Private Sub mcDateSelection_DateSelected(ByVal sender As Object ByVal e As System Windows Forms DateRangeEventArgs) Handles mcDateSelection DateSelected??????? MessageBox Show( Calendar Today s Date: mcDateSelection TodayDate vbCrLf _??????????????? Calendar Selected Start Date: mcDateSelection SelectionStart() vbCrLf _??????????????? Calendar Selected End Date: mcDateSelection SelectionEnd())??? End Sub???? 既然你只能選擇一個月中的某個特定的日期 而不是一組日期 那么 Selected Start Date和Selected End Date的值相同
現(xiàn)在 將MaxSelectionCount屬性設(shè)為 然后重新運(yùn)行代碼 這次 你就可以選擇一組日期(在這個例子中最多為 天) 而且 一旦你選擇一組日期后 你將看到如圖B所示的結(jié)果
圖B
控件的其它用法
你可以利用MonthCalendar控件的許多其它屬性和方法 使其滿足你的需要 MSDN提供使用MonthCalendar控件的更多細(xì)節(jié)
lishixinzhi/Article/program/net/201311/11787
TextBox12.Text = DateTimePicker1.Value.ToString("yyyy/MM/dd")
這樣格式化一下就可以了