TextBox.Clear() won't clear column that it Bind to.
-
I bind text box below with a string typed datarow where the column i'm going to bind is DateTime. Below id the code: this.txtDate.DataBindings.Add("Text", m_DataRow, "END_DT", true, DataSourceUpdateMode.OnPropertyChanged, null, "dd/MM/yyyy"); when i click on a chkbox event below fired:
private void chkbox_CheckedChanged(object sender, EventArgs e) { Boolean isChecked = ((CheckBox)sender).Checked; if (!isChecked) { this.txtDate.Clear() } // Line below will clear the text in text box an also clear the m_DataRow.END_DT. //if (!isChecked) //{ // this.txtDate.Clear() // m_DataRow.SetEND_DTNull() //} }
Date that show in the textbox is clear. How ever the date time still exist in m_DataRow.END_DT. I Thought when i set the txtDate.Clear it should also clear the m_DataRow.END_DT some how it won't work. Please help. -
I bind text box below with a string typed datarow where the column i'm going to bind is DateTime. Below id the code: this.txtDate.DataBindings.Add("Text", m_DataRow, "END_DT", true, DataSourceUpdateMode.OnPropertyChanged, null, "dd/MM/yyyy"); when i click on a chkbox event below fired:
private void chkbox_CheckedChanged(object sender, EventArgs e) { Boolean isChecked = ((CheckBox)sender).Checked; if (!isChecked) { this.txtDate.Clear() } // Line below will clear the text in text box an also clear the m_DataRow.END_DT. //if (!isChecked) //{ // this.txtDate.Clear() // m_DataRow.SetEND_DTNull() //} }
Date that show in the textbox is clear. How ever the date time still exist in m_DataRow.END_DT. I Thought when i set the txtDate.Clear it should also clear the m_DataRow.END_DT some how it won't work. Please help.Did you call m_DataRow.AcceptChanges()? On a side note, if the user unchecks the button, do not clear the text box, just make it read-only and ignore its content. If the user changes his mind, just make it editable again and he won't have to re-enter it.
----- If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
-
I bind text box below with a string typed datarow where the column i'm going to bind is DateTime. Below id the code: this.txtDate.DataBindings.Add("Text", m_DataRow, "END_DT", true, DataSourceUpdateMode.OnPropertyChanged, null, "dd/MM/yyyy"); when i click on a chkbox event below fired:
private void chkbox_CheckedChanged(object sender, EventArgs e) { Boolean isChecked = ((CheckBox)sender).Checked; if (!isChecked) { this.txtDate.Clear() } // Line below will clear the text in text box an also clear the m_DataRow.END_DT. //if (!isChecked) //{ // this.txtDate.Clear() // m_DataRow.SetEND_DTNull() //} }
Date that show in the textbox is clear. How ever the date time still exist in m_DataRow.END_DT. I Thought when i set the txtDate.Clear it should also clear the m_DataRow.END_DT some how it won't work. Please help.Try using txtDate.DataBindings.Remove to remove the databinding, then clear the textbox.
I get all the news I need from the weather report.