在组合框的基础上编辑组合框的文本。 [英] Chnage the text of comboboxes on the basis of a combobox.

查看:64
本文介绍了在组合框的基础上编辑组合框的文本。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望当我在一个组合框中更改文本时,其他组合框的文本应该更改。一些组合框从其他表中填充并在与forgien键相同的表中使用。请帮助,我的意思是我有一个表格,有物品和属性,价格,重量等,我希望当我更改项目名称的属性,重量,价格等也应该是chnage,而proeperties,重量,价格从数据库填充它们不存储为组合文件,

i want that when i change the text in one combobox the text of other comboboxes should be change .some of comboboxes are populated from other tables and used in the same table as forgien keys. please help, i mean i have a form which have items and properties, price, weight etc, i want that when i change item name the properties, weight, price ect should also be chnage while the proeperties, weight, price are populated from database they are not stored as comboboxitems,

推荐答案

Imports System.Data.Odbc

Public Class Form1

Dim cn As New OdbcConnection(dsn = assam server)

Dim adp As OdbcDataAdapter

Private Sub cmbMaster_SelectedValueChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)处理cmbMaster.SelectedValueChanged

adp =新的OdbcDataAdapter(select * from employeedet where employeeid ='&cmbMaster.SelectedValue.ToString()&',cn)

Dim ds作为新数据集

adp.Fill(ds)

cmbDetail.DataSource = ds.Tables(0)

cmbDetail.DisplayMember =工资

cmbDe tail.ValueMember =salary

End Sub



Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs )处理MyBase.Load

adp =新OdbcDataAdapter(select * from employee,cn)

Dim ds As New DataSet

adp。填写(ds)

cmbMaster.DataSource = ds.Tables(0)

cmbMaster.DisplayMember =employeename

cmbMaster.ValueMember = employeeid

End Sub

End Class
Imports System.Data.Odbc
Public Class Form1
Dim cn As New OdbcConnection("dsn=assam server")
Dim adp As OdbcDataAdapter
Private Sub cmbMaster_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbMaster.SelectedValueChanged
adp = New OdbcDataAdapter("select * from employeedet where employeeid='" & cmbMaster.SelectedValue.ToString() & "'", cn)
Dim ds As New DataSet
adp.Fill(ds)
cmbDetail.DataSource = ds.Tables(0)
cmbDetail.DisplayMember = "salary"
cmbDetail.ValueMember = "salary"
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
adp = New OdbcDataAdapter("select * from employee", cn)
Dim ds As New DataSet
adp.Fill(ds)
cmbMaster.DataSource = ds.Tables(0)
cmbMaster.DisplayMember = "employeename"
cmbMaster.ValueMember = "employeeid"
End Sub
End Class


你想要改变其他文本的组合框文本,因为你有写一个关于seleted值改变的代码。

你必须用其他组合框绑定数据。基于第一个组合框
on which combobox text u want to change the text of other,for that u have to write the code on seleted value changed .
there u have to bind data with other combo box.based on 1st combo box


这篇关于在组合框的基础上编辑组合框的文本。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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