0

I have embedded several different tabs in a C # form of Windows and I want to use a save button for all of those tabs, but in such a way that this button only works by going to each tab for the same tab, not for tabs. Now I want to do this using the switch but I get the following error, thank you for your help

Error: Cannot convert method group 'Focus' to non-delegate type 'int'. Did you intend to invoke the method?

private void BtnSave_Click(object sender, EventArgs e)
{
    var tst1 = 0;

    switch (tst1)
    {
        case Tabp1.Focus:
            ListViewItem item = listView1.Items.Add(NameTB.Text);
            item.SubItems.Add(FamilTB.Text);
            item.SubItems.Add(AgeMTB.Text);
            item.SubItems.Add(ForceStatusCobx.Text);
            item.SubItems.Add(ForceTypeCobx.Text);
            item.SubItems.Add(PhNumMTB.Text);
            item.SubItems.Add(PirsonaliCodeMTB1.Text);


            NameTB.Text = string.Empty;
            FamilTB.Text = string.Empty;
            AgeMTB.Text = string.Empty;
            ForceStatusCobx.Text = string.Empty;
            ForceTypeCobx.Text = string.Empty;
            PhNumMTB.Text = string.Empty;
            ForceTypCobx.Text = string.Empty;
            PirsonaliCodeMTB1.Text = string.Empty;

            MessageBox.Show(
                "INFO IS register!",
                "Successful operation",
                MessageBoxButtons.OK,
                MessageBoxIcon.Asterisk
                );
            break;
    }
}
David L
  • 32,885
  • 8
  • 62
  • 93
Amir
  • 1
  • I believe focus is a method, not a property – Andre.Santarosa Feb 19 '22 at 14:08
  • Do you have the right answer? – Amir Feb 19 '22 at 14:10
  • `.Focus()` is a method (that returns `bool`) -- It's not clear what you're trying to do nor what *this button only works by going to each tab for the same tab, not for tabs* means. Try to improve the description of the problem and what that `switch` is used for. – Jimi Feb 19 '22 at 14:13
  • I'm actually trying to do a project that has multiple tabs embedded, using just one save button; Do this in all tabs (save data in all tabs and pages using the same button, except that in each page this button should do almost the same scenario but different) I hope I was able to Reach out.... – Amir Feb 19 '22 at 14:24

0 Answers0