Button to check CheckBox

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
		// End Wizard Added Custom Method Calls
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void epiButtonC1_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
	
	EpiDataView WillsAwesomeDV = (EpidataView)(oTrans.EpidataViews["OrderHed"]);
    WillsAwesomeDV.dataView.[WillsAwesomeDV.Row]["Checkbox14"] = true;
	}
}
    private void epiButtonC1_Click(object sender, System.EventArgs args)
    {
        // ** Place Event Handling Code Here **

        EpiDataView WillsAwesomeDV = (EpiDataView)(oTrans.EpiDataViews["OrderHed"]);
        WillsAwesomeDV.dataView.[WillsAwesomeDV.Row]["Checkbox14"] = true;
    }

casing issue

And you better be just doing this for a test, and redoing all of this later with NAMES ON YOUR CONTROLS!

If you leave your button as “epiButtonC1” then…

I don’t see it. :sweat_smile: :person_shrugging: :person_shrugging: :sweat_smile:

Capital D in EpiDataViews

I’m assuming that is line 73. I asked for a screen shot, because then I could see which line it’s complaining about.

I was going cross eyed. LOL! Changed it, still same error.

ah, the . after dataView doesn’t belong there.

WillsAwesomeDV.dataView[WillsAwesomeDV.Row]["Checkbox14"] = true;
1 Like

That compiled!

ok, then 2 questions.

  1. Does it work the way you want it to now?

and

  1. Do you understand the code that you just put into the system so you could do it again somewhere else?
1 Like

Sorry for the delay, I had a family emergency last night and couldn’t respond quickly.

  1. No, it doesn’t function as expected. I am needing it to set the checkbox to true, but when I run a baq on it, the checkbox shows false.

  2. Yes. Your explanation made sense and I do have it in my personal cheatsheet notes for next time. Because, there will be a next time! :joy: :joy:

First step, is your button firing? (add a message box popup using MessageBox.Show("My Button Works"); to make sure that the button is firing. Or, if you have the checkbox displayed on the screen, you should see that change.

Second, Did you save the record before you checked in with the BAQ? This will only change it in the dataset and won’t go into effect until you hit save.

If that still doesn’t work, you may also have to update the RowMod to notify the system. (You shouldn’t have to, but that’s what I would look at next)

It works. I just needed to hit the button. Wait a few moments, and then save. After that, it worked just fine.

Thank you!

Thinking out loud, is it possible to have it saved automatically after it is checked? Any potential issues with doing something like that from your experience?

No, that’s fine. You should be able to search the forum for the code to add to the button to save the record.

1 Like

FWIW…
Here is a really simple UD40 form customization export… seems to work.
The button toggles checkbox values and an oTrans.Update saves.

UD40_ToggleCheckBoxes.xml (30.6 KB)

1 Like