0

I'm new to C# and am working on this project

My code:

    private static void Anonymize(ElementList elementList)
    {
        string name = textBox3.Text;
        Anonimize(elementList.Get(DicomTag.PatientsName), PatientNames, "Patient Name " + name);
    }

when Anonimize method parameters are:

private static void Anonimize(Element element, Dictionary<string, string> dic, string pattern)

I would like to know how to be able to type in the patients name into a text box and have the program use it in the static method. The program needs to stay static and I can't add a textbox parameter because that will mess with my other code. Any help would be greatly appreciated.

1 Answer 1

1

Create a static variable in your Form to reference textBox3 and assign it in the Load() event of the Form. Then change your method to use that static variable instead:

private static TextBox tb;

private void Form1_Load(object sender, EventArgs e)
{
    tb = this.textBox3;
}

private static void Anonymize(ElementList elementList)
{
    string name = tb.Text;
    Anonimize(elementList.Get(DicomTag.PatientsName), PatientNames, "Patient Name " + name);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.