简体   繁体   English

组合框项目连接到C#Winforms中的列表

[英]combobox items connect to column table in C# winforms

i have a form:"Emloyees" with a combobox1. 我有一个表格:带有组合框1的“员工”。 i have a table "City". 我有一张桌子“城市”。 when I add an emloyee to the my "Emloyees" table I open the comboBox1 all the cities i have and i choose one. 当我在“员工” 表中添加员工时,我打开comboBox1我拥有的所有城市,然后选择一个。 if in the table City I add a city, I want that when i try to add an emloyee when I open the comboBox1 there will be the city i just add. 如果在“城市”表中添加城市,我希望当我在打开comboBox1时尝试添加员工时,将会有我刚刚添加的城市。 i want a connection between the table City and the comboBox1 in the form 我想要表格City和comboBox1之间的连接形式

You need to make an sql query that get the Employee and then you can display it in the combobox 您需要进行一个获取Employee的sql查询,然后可以在组合框中显示它

i have similar project so i know 我有类似的项目,所以我知道

its something like that 它是这样的

  CityComboBoxEmp.DataSource = CityShow.UseSqlCommand("Select * From City").Tables[0];

CityShow is use class that's runing sql commands CityShow是正在运行sql命令的使用类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM