Combobox not Responsive
-
I can't seem to make the Combobox4 text to reflect the changes made and still pointing to the "Edit..." Dim mylink As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Application.StartupPath + "\Data\BW.mdb") If Me.ComboBox4.Text = "Edit..." Then Dim NewLink As String = InputBox("Type the desired URL to Business Warehouse Inbound", "Business Warehouse SAP") If NewLink.Length > 0 Then Dim Outbound As String = "UPDATE _servername SET Outstring ='" + NewLink + "'" Dim OutFld As OleDb.OleDbCommand = New OleDb.OleDbCommand(Outbound, mylink) Dim affectedrows As Integer mylink.Open() OutFld.Prepare() affectedrows = OutFld.ExecuteNonQuery() mylink.Close() End If End If Dim sql As String = "SELECT * FROM _servername" 'Refresh Dim da = New OleDb.OleDbDataAdapter(sql, mylink) Dim dtSvr As New Data.DataTable("_servername") da.Fill(dtSvr) Me.ComboBox4.Text = (dtSvr.Rows(0).Item("Outstring")).ToString
-
I can't seem to make the Combobox4 text to reflect the changes made and still pointing to the "Edit..." Dim mylink As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Application.StartupPath + "\Data\BW.mdb") If Me.ComboBox4.Text = "Edit..." Then Dim NewLink As String = InputBox("Type the desired URL to Business Warehouse Inbound", "Business Warehouse SAP") If NewLink.Length > 0 Then Dim Outbound As String = "UPDATE _servername SET Outstring ='" + NewLink + "'" Dim OutFld As OleDb.OleDbCommand = New OleDb.OleDbCommand(Outbound, mylink) Dim affectedrows As Integer mylink.Open() OutFld.Prepare() affectedrows = OutFld.ExecuteNonQuery() mylink.Close() End If End If Dim sql As String = "SELECT * FROM _servername" 'Refresh Dim da = New OleDb.OleDbDataAdapter(sql, mylink) Dim dtSvr As New Data.DataTable("_servername") da.Fill(dtSvr) Me.ComboBox4.Text = (dtSvr.Rows(0).Item("Outstring")).ToString
Is the combobox's
DropDownStyle
equal toDropDownEditList
. If it is, yuo should change it toDropDown
. If that's not the case, use debugger to see that the ComboBox4.Text is set correctly. Just a sidenote, you should use parameters in your sql commands instead of concatenating.The need to optimize rises from a bad design.My articles[^]
-
Is the combobox's
DropDownStyle
equal toDropDownEditList
. If it is, yuo should change it toDropDown
. If that's not the case, use debugger to see that the ComboBox4.Text is set correctly. Just a sidenote, you should use parameters in your sql commands instead of concatenating.The need to optimize rises from a bad design.My articles[^]
The Combobox4.Text shown correctly then afterwards (like refresh) it went to the selected item called "edit..." see my codes
-
The Combobox4.Text shown correctly then afterwards (like refresh) it went to the selected item called "edit..." see my codes
So do you mean that after executing this line:
Me.ComboBox4.Text = (dtSvr.Rows(0).Item("Outstring")).ToString
the text in combobox is something else than "Edit..."? If so, when does it change back to "Edit..."?
The need to optimize rises from a bad design.My articles[^]
-
So do you mean that after executing this line:
Me.ComboBox4.Text = (dtSvr.Rows(0).Item("Outstring")).ToString
the text in combobox is something else than "Edit..."? If so, when does it change back to "Edit..."?
The need to optimize rises from a bad design.My articles[^]
I don't know. I even tried to combobox4.Items.Empty() and that would not do anything to make the Me.ComboBox4.Text = (dtSvr.Rows(0).Item("Outstring")).ToString
-
I don't know. I even tried to combobox4.Items.Empty() and that would not do anything to make the Me.ComboBox4.Text = (dtSvr.Rows(0).Item("Outstring")).ToString
Is the combobox bound to a datasource? Also instead of changing the text, you should try to set the selectedindex. If the text isn't already in the combobox list you can add it through Items collection (or by refreshing bindings if the list comes from a datasource).
The need to optimize rises from a bad design.My articles[^]
-
Is the combobox bound to a datasource? Also instead of changing the text, you should try to set the selectedindex. If the text isn't already in the combobox list you can add it through Items collection (or by refreshing bindings if the list comes from a datasource).
The need to optimize rises from a bad design.My articles[^]
This is triggered the Combobox4 prior to clicking the dropdown box and pick "Edit..." If edit is picked than the other code kicks in. Does the Combobox look bounded here? Dim mylink As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Application.StartupPath + "\Data\BW.mdb") Dim sql As String Dim da As OleDb.OleDbDataAdapter Dim cmd As OleDb.OleDbCommand Dim objCmd As New OleDb.OleDbCommand Dim ds As New DataSet Dim affectedRows As Integer sql = "SELECT * FROM _servername" 'Reading the all the fields from the MDB file da = New OleDb.OleDbDataAdapter(sql, mylink) Dim dtSvr As New Data.DataTable("_servername") da.Fill(dtSvr) Me.ComboBox3.Text = dtSvr.Rows(0).Item("Instring") Me.ComboBox4.Text = dtSvr.Rows(0).Item("Outstring") Me.Panel2.BringToFront() Me.ComboBox3.Items.Add("Edit...") Me.ComboBox4.Items.Add("Edit...")
-
This is triggered the Combobox4 prior to clicking the dropdown box and pick "Edit..." If edit is picked than the other code kicks in. Does the Combobox look bounded here? Dim mylink As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Application.StartupPath + "\Data\BW.mdb") Dim sql As String Dim da As OleDb.OleDbDataAdapter Dim cmd As OleDb.OleDbCommand Dim objCmd As New OleDb.OleDbCommand Dim ds As New DataSet Dim affectedRows As Integer sql = "SELECT * FROM _servername" 'Reading the all the fields from the MDB file da = New OleDb.OleDbDataAdapter(sql, mylink) Dim dtSvr As New Data.DataTable("_servername") da.Fill(dtSvr) Me.ComboBox3.Text = dtSvr.Rows(0).Item("Instring") Me.ComboBox4.Text = dtSvr.Rows(0).Item("Outstring") Me.Panel2.BringToFront() Me.ComboBox3.Items.Add("Edit...") Me.ComboBox4.Items.Add("Edit...")
No it's not bound based on this, but if you have set the DataSource property in designer it is bound in code-behind file. However, since you have code on several event handlers, I suggest that you put a breakpoint in every eventhandler where combobox4 is modified whether the eventhandler is for combobox4 or another object. When debugging the debugger should hit your breakpoint(s) and give you more info how/why the text is modifed. Perhaps the events are raised in different order than you expect or some code is called, which "resets" that combo.
The need to optimize rises from a bad design.My articles[^]