c# - Check state of combobox and change textbox readonly -
I have a form that shows the gridviewview and the text box and the combo box. When the name of a column is selected in the blankbox, and filters and displays the data searched in the text written in the text box. How can I know that kickbox does not have any selection, and to change the text box to the right position only for reading, and when something is selected, then convert it back to false so that I can search?
DataTable dt; Private Zero Searchform_load (Object Sender, EventEurge E) {SqlCeConnection con = New SqlCeConnection (@ "Data Source = | DataDirectory | \ LWADataBase.sdf;"); SqlCeDataAdapter sda = New SqlCeDataAdapter ("Choose TBL from Customers", Con?); Dt = new datatable (); Sda.fill (dt); DataGridView1.DataSource = dt; ComboSearch.Items.Add ("[first name]"); ComboSearch.Items.Add ("Surename"); ComboSearch.Items.Add ("[Address Line 1]"); ComboSearch.Items.Add ("[Address Line 2]"); ComboSearch.Items.Add ("county"); ComboSearch.Items.Add ("[postcode]"); ComboSearch.Items.Add ("[Contact Number]"); ComboSearch.Items.Add ("[email address]"); } Private Waste Search Txt_TextChanged (Object Sender, EventArggs E) {{DataView DV = New DataView (DT); Dv.rowfilter = "" + comboSearch.Text.Trim () + "like '%" + searchTxt.Text.Trim () + "%'"; DataGridView1.DataSource = DV; }}
You can try it
If (ComboBox.SelectedItem == faucet) {// Some TextBox.ReadOnly = true; // Use TextBox. Readonly property} other {Textbox.ReadOnly = false; }
Hope this helps you!
Comments
Post a Comment