how do i write the new command that clears records

Recommended Answers

new creates objects, it doesn't 'clear records'. Can you be more descriptive of what you are trying to accomplish?

Jump to Post

All 4 Replies

new creates objects, it doesn't 'clear records'. Can you be more descriptive of what you are trying to accomplish?

When you use new you create a blank version of the object in question (hence new). What records are you trying to clear? Most collections have a built in method to clear them of all current data.

AM TRYING TO CLEAR RECORDS FROM THE TEXBOXES N COMBOBOXES INSTEAD OF DOING IN MANUALLY

In that case you can loop through the controls in the form and either reset the text for all of them or for a particular type of control (textbox for example).

foreach (Control ctrl in this.Controls)
     {
          if (ctrl is TextBox)
          {
              ctrl.Text = "";
          } else if (ctrl is ComboBox) {
              ctrl.Items.Clear();
          }
     }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.