Suggested API improvment for working with controls on a form  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Suggested API improvment for working with controls on a form

Postby SBarnes » Sun Aug 07, 2016 5:27 pm

Whilst Scott gave an excellent example of adding controls to a form (viewtopic.php?f=27&t=404&p=1306&hilit=add+control#p1306)

and you can use something like

if (JiwaForm.GetType() == typeof(JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm))
{
JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm salesform = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)JiwaForm;
TableLayoutPanel parentpanel = (TableLayoutPanel)(salesform.Controls.Find("TableLayoutPanel2", true)[0]);
UltraTextEditor matchdelstate = (UltraTextEditor)(salesform.Controls.Find("txtDeliveryState", true)[0]);
}

to find controls would it be possible to add to the generic maintenance form a GetControlByName("ControlName", SearchChildren) function?

And some sort of SetControlValueByName and GetControlValueByName would also be nice if possible as well.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Suggested API improvment for working with controls on a  Topic is solved

Postby Mike.Sheen » Sun Aug 07, 2016 6:33 pm

Hi Stuart,

Bug 12928 has been added to address this

Mike

PS:

Also, instead of:

Code: Select all
if (JiwaForm.GetType() == typeof(JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm))


Why not use:

Code: Select all
if (JiwaForm is JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)


I think they are equivalent - I tend to use the latter in C#, but perhaps I'm overlooking something.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Suggested API improvment for working with controls on a

Postby Scott.Pearce » Tue Aug 09, 2016 2:29 pm

The .Net framework already has this:

Code: Select all
Control[] myControls = myForm.Controls.Find("MyControlName",true);
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Suggested API improvment for working with controls on a

Postby SBarnes » Tue Aug 09, 2016 2:37 pm

Hi Scott

Yes it does and the code I provided in the original post does that call but the problem is it assume that an array with element zero comes back every time which may not be the case I left out the error handling for simplicity what I was suggesting for a function was to cover of the error handling and probably return null/nothing if not found.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests