Updating textNotes from a Plugin

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
wjstarck
Posts: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Updating textNotes from a Plugin

Post by wjstarck » Sun Nov 08, 2020 10:33 am

I have a need to update textNotes on FormProcEdit via a plugin.

Right now, I have it all working by making FillControlsOnStartup() method public and then calling it from my plugin after FormProcEdit has loaded but before it is clsoed.

Any way of getting a public FillTextNotes method added to FormProcEdit? If not, what other way could I use the subscribe textNotes control to the output of my plugin?
Last edited by wjstarck on Sun Nov 08, 2020 11:50 am, edited 1 time in total.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
jordansparks
Site Admin
Posts: 5739
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: Updating textNotes from a Plugin

Post by jordansparks » Sun Nov 08, 2020 10:40 am

How about a hook at the end of FillControlsOnStartup()?
Jordan Sparks, DMD
http://www.opendental.com

User avatar
wjstarck
Posts: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Updating textNotes from a Plugin

Post by wjstarck » Sun Nov 08, 2020 12:12 pm

Can't seem to get that to work.

Here's what I'm doing:

1) Placing a hook for a button on FormProcEdit at the bottom of FormLoad or FillControlsOnStartup()
2) Clicking the button launches a window where the user can select item(s) from a list of strings
3) Building a note based on the selection
4) Inserting the note from Step #3 into textNotes before form close.

if I add my hook at the bottom of FillControlsOnStartup, textNotes doesn't refresh with the newly built note.
Last edited by wjstarck on Sun Nov 08, 2020 3:47 pm, edited 2 times in total.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
wjstarck
Posts: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Updating textNotes from a Plugin

Post by wjstarck » Sun Nov 08, 2020 12:15 pm

This is where I was adding FillControlsOnStartup():

Code: Select all

		public static void butLocal_Click(object sender, EventArgs e) {
			FormAddNotes formAN = new FormAddNotes(0, sender, _procCur, textNotes);
			formAN.ShowDialog();
			if (formAN.DialogResult == DialogResult.OK) {
				_procCur.Note = formAN.localNote;
				textNotes.Text = _procCur.Note;
				formPE.FillControlsOnStartup(); <-----------------------------------
			}
		}
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

joes
Posts: 239
Joined: Tue Aug 13, 2019 12:41 pm

Re: Updating textNotes from a Plugin

Post by joes » Mon Nov 09, 2020 1:41 pm

If I am correctly understanding your configuration, I think that you can add the button to the form with the hook at the end of FillControlsOnStartup() that Jordan suggested, then you could assign the string from your form to textNotes by accessing it through the parent form that it shares with the button you added. The code would look something like this:

Code: Select all

public static void butLocal_Click(object sender, EventArgs e) {
	FormAddNotes formAN = new FormAddNotes(0, sender, _procCur, textNotes);
	formAN.ShowDialog();
	if (formAN.DialogResult == DialogResult.OK) {
		Form parentForm = ((Control)sender).FindForm();
                Control[] arrayControls = parentForm.Controls.Find("textNotes",true);
		arrayControls[0].Text = formAN.localNote;
	}
}
Edit: I realized that the code suggested above is not the best solution. A hook will give access to the instance of FormProcEdit which can be used to get and set all of its controls. This makes the call to FindForm() unnecessary. Assuming that _procCur and textNotes in the butLocal_Click() method are references to the same objects in FormProcEdit, setting _procCur.Note and textNotes.Text should be all that is needed.
Last edited by joes on Wed Nov 11, 2020 1:23 pm, edited 1 time in total.
Joe Sullivan
Open Dental Software
http://www.opendental.com

User avatar
jordansparks
Site Admin
Posts: 5739
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: Updating textNotes from a Plugin

Post by jordansparks » Mon Nov 09, 2020 10:30 pm

I can't figure out why you need to call FillControlsOnStartup again. It was already called once, and it's only designed to be called once. It looks like you've set textNotes.text in the line above, so why are you saying textNotes isn't refreshing? That makes no sense. You've clearly set it.
Jordan Sparks, DMD
http://www.opendental.com

User avatar
wjstarck
Posts: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Updating textNotes from a Plugin

Post by wjstarck » Tue Nov 10, 2020 5:01 am

Yes, that's it.

Thanks
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

Post Reply