There is a button on the form with this code

private void q1z_Click(object sender, EventArgs e) { WordDocument wordDoc = null; try { wordDoc = new WordDocument(pathToTemplate); if (q1.Checked) { wordDoc.ReplaceAllStrings(q1marks.Text, q1.Text); } else { wordDoc.SetSelectionToText(q1marks.Text); wordDoc.Selection.Text = q1.Text; } } catch (Exception error) { if (wordDoc != null) { wordDoc.Close(); } MessageBox.Show("Ошибка ΠΏΡ€ΠΈ Π·Π°ΠΌΠ΅Π½Π΅ тСкста Π½Π° ΠΌΠ΅Ρ‚ΠΊΠ΅ Π² Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π΅ Word. ΠŸΠΎΠ΄Ρ€ΠΎΠ±Π½ΠΎΡΡ‚ΠΈ " + error.Message); return; } wordDoc.Visible = true; 

and 2 textboxes, in one I write a label, for example @@ a, in the second a text that will replace this label in the Word. With the help of the checkbox, you can also replace all labels with your own text at the same time. The problem is that when compiling, the studio stresses me here if (q1.Checked) , Cheked and says (see screenshot) screen error

Tell me what kind of error it is and how to remove it, in another project, the code is the same - and everything works?

  • one
    Uh, what exactly is your q1 type, do you have to guess yourself? - VladD
  • simple string, plain textbox - Assa
  • one
    Well, where does the Checked property come from, is it not a checkbox? - VladD

0