【问题标题】:how to combine combo box contents in vb.net如何在 vb.net 中组合组合框内容
【发布时间】:2010-03-16 22:49:24
【问题描述】:

我有这个,生日选择在 3 个组合框中,1 个代表月份,1 个代表天,1 个代表年。 但是我的数据库表只有这个生日属性(没有年月日)。 如何组合在这 3 个组合框中选择的项目,以便它们适合生日列?

【问题讨论】:

    标签: vb.net


    【解决方案1】:

    如果你的组合框中的项目是字符串,你可以这样做:

    Dim Day As Integer = Integer.Parse(ComboBoxDay.SelectedItem.ToString())
    Dim Month As Integer = Integer.Parse(ComboBoxMonth.SelectedItem.ToString())
    Dim Year As Integer = Integer.Parse(ComboBoxYear.SelectedItem.ToString())
    
    Dim MyDate As New DateTime(Year, Month, Day)
    

    【讨论】:

    • 比 user225269。而且...您是否出于特殊原因使用组合框?您可能想看看 DateTimePicker 或 MonthCalendar 控件...? :-)
    猜你喜欢
    • 2011-01-28
    • 2015-03-23
    • 1970-01-01
    • 2017-04-29
    • 2016-03-31
    • 2020-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多