我是vb.net的新手。请帮忙 [英] I am new with vb.net. please help
问题描述
您好,
我正在制作一个项目,其中我分别想要2个组合框States和Districts,如果我从中选择一个状态州组合框区域组合框将填满各州的区域名称。
任何人都请帮忙,并告诉我如何在数据库中为这个应用程序创建一个表格。
我正在使用visual studio 2010和ms access 2007
此致,
Alok。
数据库中需要两个表:状态表(例如state
)和一个区的表(例如区
)。区
表应该具有外键,状态的主键
表格,例如
州表
ID NAME
== ==== ============
1'Green State'
2'Blue State'
..
<前一行=文字>地区表
ID STATE_ID NAME
== ======== ========
1 2'快乐区'
2 5'浅绿区'
3 2'悲伤区'
..
你看,'Happy District'和'Sad District'都属于'Blue State'。
建立级联下拉菜单 -
Winforms中的级联组合框Windows窗体C#VB.NET
发布者amiT jaiN [ ^ ]
VB.NET-Windows applcation中的级联下拉列表 [ ^ ]
对于数据库,请查看此视频 https://www.youtube.com/watch?v=9HX8IYIMWiE [ ^ ]
或
Imports System.data.oledb
public class NewProject
dim conn as Oledb .oledbconnection
privat e sub connectdatabase()
conn = new oledb.oledbconnection
conn.connectionstring = Provider = Microsoft.Jet.Oledb.4.0;数据源=& application.startuppath& \ yourdatabase.mdb ' yourdatabase.mdb是您的访问文件将放在调试文件夹
conn.open()
结束 sub
=============== ================================================== =========
' 和for combobox使用此
private sub NewProject_Load()句柄 ..
connectdatabase ' 这将连接您的数据库以进行访问
States.Items.Clear()
States.Items.Add( Maharastra)
States.Items.Add( Chhattisgarh)
States.Items.Add( 比哈尔)
States.Items.Add( Gujrat)
States.Items.Add( Madhyapradesh)
' 根据需要添加状态
结束 Sub
' 关于comboxbox索引更改事件粘贴代码
如果 States.text = Madhyapradesh 然后
district.items.add( Bhopal)
d istrict.item.add( Jabalpur)
elseif States.text = Chhattisgarh 然后
district.items.add( Raipur)
district.item.add( Bilaspur)
elseif States.text = 比哈尔 then
district.items.add( Katihar)
district.item.add( Patna)
elseif States.text = Maharashtra 然后
district.items.add( Mumbai)
district.item.add( Pune)
< span class =code-keyword>结束 如果
Hello,
I am making a project in which i want 2 combo boxes "States" and "Districts" respectively, and if I select a state from the state combo box the district combo box will get filled up with the names of districts of respective state.
Any one please help and also tell me how to create a table in database for this application.
I am using visual studio 2010 and ms access 2007
Sincerely,
Alok.
You need two tables in the database: a table for States (e.gstate
) and a table for Districts (e.g.district
). Thedistrict
table should have, as foreign key, the primary key ofstate
table, e.g.
state table ID NAME == ================ 1 'Green State' 2 'Blue State' ..
district table ID STATE_ID NAME == ======== ======== 1 2 'Happy District' 2 5 'District of Light Green' 3 2 'Sad District' ..
You see, both 'Happy District' and 'Sad District' belongs to the 'Blue State'.
Build cascading dropdowns -
Cascading ComboBox In Winforms Windows Forms C# VB.NET
Posted by amiT jaiN [^]
Cascading Dropdownlists in VB.NET-Windows applcation [^]
For database look this video https://www.youtube.com/watch?v=9HX8IYIMWiE[^]
or
Imports System.data.oledb public class NewProject dim conn as Oledb.oledbconnection private sub connectdatabase() conn = new oledb.oledbconnection conn.connectionstring = "Provider = Microsoft.Jet.Oledb.4.0;Data source =" & application.startuppath & "\yourdatabase.mdb" 'yourdatabase.mdb is your access file will put on debug folder conn.open() End sub ========================================================================== 'and for combobox use this private sub NewProject_Load() Handles.. connectdatabase 'this will connect your database to access States.Items.Clear() States.Items.Add("Maharastra") States.Items.Add("Chhattisgarh") States.Items.Add("Bihar") States.Items.Add("Gujrat") States.Items.Add("Madhyapradesh") 'Add states as required End Sub 'on comboxbox index change event paste below code if States.text = "Madhyapradesh" then district.items.add("Bhopal") district.item.add("Jabalpur") elseif States.text = "Chhattisgarh" then district.items.add("Raipur") district.item.add("Bilaspur") elseif States.text = "Bihar" then district.items.add("Katihar") district.item.add("Patna") elseif States.text = "Maharashtra" then district.items.add("Mumbai") district.item.add("Pune") End if
这篇关于我是vb.net的新手。请帮忙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!