什么相当于组合框的c#窗体中vb6的组合框属性'ItemData' [英] What is equivalent of combobox's property 'ItemData' of vb6 in c# windows forms of combobox

查看:95
本文介绍了什么相当于组合框的c#窗体中vb6的组合框属性'ItemData'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的名字是vishal。

我想知道 ItemData List 组合框属性等同于什么使用sql server2008在 c#windows窗体中的 vb6
我知道这是一个天真的问题,但有了这个答案,我可以解决我的其他问题c#windows窗体中的组合框。

下面给出了使用ItemData属性的vb6中的代码和组合框中的List属性到Ms访问中名为: dialyser 的表。

hi my name is vishal.
I was wondering what is equivalent of combobox properties of ItemData and List of vb6 in c# windows forms with sql server2008?
I know this is naive question but with this answer i can solve my other problems with combobox in c# windows forms.
Given below is code in vb6 of using ItemData property and List property of combobox into table named:dialyser in Ms access.

Private Sub loadPatientID()
    On Error GoTo errh
    Dim vSQLStr As String
    Dim LPatientID As String
    vSQLStr = "select p.patient_id as patient_id,n.patient_first_name as patient_fname, n.patient_last_name as patient_lname from patient_name n,patient_id p where n.patient_id=p.patient_id and n.status = true and p.patient_id not in (select patient_id from dialyser where deleted_status=false);"
    Dim oRS As New ADODB.Recordset
    If (adoDatabase.State = 0) Then
        adoDatabase.Open
    End If
    oRS.Open vSQLStr, adoDatabase, adOpenForwardOnly, adLockReadOnly
    
    cboPatientID.Clear
    Do While Not oRS.EOF
         '// Do something with the data'
         LPatientID = oRS.Fields("patient_id").Value
         LPatientID = Replace(Space(6 - Len(LPatientID)) & LPatientID, " ", "0")
         cboPatientID.AddItem oRS.Fields("patient_fname").Value & " " & oRS.Fields("patient_lname").Value & "|" & LPatientID
         cboPatientID.ItemData(cboPatientID.NewIndex) = oRS.Fields("patient_id").Value
         oRS.MoveNext
    Loop
    oRS.Close
    Exit Sub
errh:
    MsgBox Err.Description, vbCritical
End Sub
Private Sub Command5_Click()
On Error GoTo errh
Public adoDatabase As New ADODB.Connection
Dim rs As ADODB.Recordset
If (adoDatabase.State = 0) Then
        adoDatabase.Open
rs.Open "dialyser", adoDatabase, adOpenKeyset, adLockOptimistic, adCmdTable
rs.AddNew
    rs("dialyserID").Value = txtDID.Text
    rs("manufacturer").Value = cboManufacturer.Text
    rs("mfr_ref_number").Value = TxtMFRRefNo.Text
    rs("mfr_lot_number").Value = TxtMFRLotNo
    rs("mfr_date").Value = CDate(dtMFRDate.Value)
    rs("exp_date").Value = CDate(dtMFRExpDate.Value)
    rs("start_date").Value = CDate(dtMFRStartDate.Value)
    rs("packed_volume").Value = TxtPVol.Text
    rs("dialyzer_size").Value = cboequipmentType.Text
    rs("patient_id").Value = cboPatientID.ItemData(cboPatientID.ListIndex)
    rs("row_upd_date").Value = CDate(Now)
    rs("user_id").Value = pUserID
    rs.Update
MDIForm1.updateUserActivities rs("agn").Value, 4, txtDID.Text & " - Dialyzer detail was successfully assigned to the patient - (" & cboPatientID.List(cboPatientID.ListIndex) & ")"
    MsgBox "Dialyzer detail was added successfully", vbInformation
    Unload Me
    Exit Sub
errh:
    MsgBox Err.Description, vbCritical
End Sub



其中 cboPatientID 是带有Ms访问权限的vb6 adodb中我的组合框的名称。

我只是想知道什么是相同的组合框( cboPatientID )属性 ItemData 和c#windows窗体中的vb6的列表。任何人都可以帮助我吗?解决这个问题的任何帮助或指导都将是非常感谢。


where cboPatientID is name of my combobox in vb6 adodb with Ms access.
I just want to know what is equivalent of combobox(cboPatientID) properties ItemData and List of vb6 in c# windows forms.Can anyone help me please?Any help or guidance in solving of this problem would be greatly appreciated.

推荐答案

使用 displaymember valuemember



链接中提供的示例是listbox,你可以在组合框中使用相同的代码
use displaymember and valuemember

The example provided there in the link is listbox you can use the same code in combobox also


这篇关于什么相当于组合框的c#窗体中vb6的组合框属性'ItemData'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆