combo box items need to be updated after saving an new item from another tab
I have 2 tabs in a window form using Microsoft Visual Studio 2008.1st tab
is about Group.2nd tab is about Category.In 1st tab,I've already finished
to save,delete and update group data into "Group_tbl".In 2nd tab,I have a
group name combo box that is databinding with "Group_tbl" display "group
name" Group_tbl contains following fields. group_id group_name
group_description
The problem is - Unexpectedly,I need to save new group while I'm working
on 2nd tab.So,I go to 1st tab and saving group_id >>> "Med",group name >>>
"Medicine".Data saved successfully.Then,I go back into 2nd tab.The combo
box I'm binding with group_tbl is not updated.It's needed keeping update
after adding new entry.I realize it's updated when I close the program and
reload it.But,it's not convenient for users.I've tested refresh()
method.Nothing changed.There's no coding to show because the combo box is
mostly done by assigning properties in design form.I also tried this -
Private Sub cboCatGroupName_MouseClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles cboCatGroupName.MouseClick
GetDataConn(".\SQLEXPRESS", "rightstock", True)
Dim dataadapter As New SqlDataAdapter("SELECT group_name FROM
group_tbl", sqlConn)
Dim ds As New DataSet()
dataadapter.Fill(ds, "group_tbl")
sqlConn.Close()
cboCatGroupName.DataSource = ds
cboCatGroupName.DisplayMember = "group_tbl"
It doesn't show any error.And it's not updated.Actually,this is my first
time experience with databound combo box.I think I have a problem in
handling events and data adapter filling.
So,I'll be glad if somebody helps me.Really appreciate for all advices and
thank you all.
No comments:
Post a Comment