The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Modifying a Form on-the-fly (i.e. visibility)
Posted: 12 Jan 09 5:17 AM
|
Hi
Another quick question for all your super developers !
I'm trying to use a combo box to modify the appearance of the form, such that the selected value of that combobox will determine which elements to show on the form. I can get this to work pretty easily by using a combination of a switch statement and the controlid.visible = [true | false] statement.
However, whilst the control appears or disappears the caption remains. How can I force the caption to go invisible too? Alternatively, is there a way of making the whole "cell" in the form structure to become visible/invisible?
One more question, is there any way to redraw the form and move the controls around in code? Am I right in thinking that the controls position is used in the code, and can't be changed on-the-fly?
Thanks for the help
David |
|
|
|
Re: Modifying a Form on-the-fly (i.e. visibility)
Posted: 12 Jan 09 9:56 AM
|
Managed to work out how to set a control's caption to visible/invisible...
The caption has it's own controlid taking the format control_lbl. This does not include autocomplete, so it's difficult to know what options are available, but the visible property definitely exists and works.
However, I'm still interested to know whether I can rearrange the layout of the controls without mullering the code in the form.
Cheers |
|
|
| |
|
Re: Modifying a Form on-the-fly (i.e. visibility)
Posted: 13 Jan 09 11:23 AM
|
Muller: (pronounced like the yoghurt) To completely destroy something and make it not work etc. "When Bob accidently removed all the semi-colons from his code it mullered the whole program" |
|
|
|
Re: Modifying a Form on-the-fly (i.e. visibility)
Posted: 13 Jan 09 11:23 PM
|
Originally posted by David Lumm
Muller: (pronounced like the yoghurt) To completely destroy something and make it not work etc. "When Bob accidently removed all the semi-colons from his code it mullered the whole program" |
|
Haha - I use another word (and way too frequently)  |
|
|
|
Re: Modifying a Form on-the-fly (i.e. visibility)
Posted: 27 Feb 09 8:22 AM
|
David, did you ever get a method to do this?
I've a similar issue now and it's doing my nut. The show/hide is easy, but looks like crap as the various controls are spread around. I've come up with a handful of bad ideas on this, none of which have worked out particularly well.
Cheers, Mark |
|
|
|
Re: Modifying a Form on-the-fly (i.e. visibility)
Posted: 27 Feb 09 9:41 AM
|
Unfortunately not. There are a couple of options:
1. SalesLogix renders a Control Container as a asp:Panel, which may allow you to do some slightly cleverer stuff - e.g. create an empty container and then add controls to it on the fly:
TextBox text = new TextBox(); text.Text = "something"; panel.Controls.Add(text); Code adapted from http://forums.asp.net/p/1371106/2870791.aspx Clearly the example I've given is pretty simple, but hopefully you get the idea.
2. Transfer the form into a custom smartpart, then you can give the DIVs IDs and start showing/hiding whole divs...
Sorry I can't help you more! |
|
|
|
Re: Modifying a Form on-the-fly (i.e. visibility)
Posted: 02 Mar 09 9:21 AM
|
Thanks David. These were two of idea's I'd already looked at.
The first one was the first thing I tried myself, but I rejected it due to being unable to attach an OnChange script to the field I was creating manually (Which would be a requirement for me in this case).
Has anyone had any luck adding an onchange script to a field manually created and added to a smart part in this manner?
Cheers, Mark |
|
|
|
Re: Modifying a Form on-the-fly (i.e. visibility)
Posted: 02 Mar 09 9:52 AM
|
I've not had any experience of doing it, or it working, but surely it would just be a case of replicating the way that SalesLogix does it itself?
protected override void OnWireEventHandlers() { base.OnWireEventHandlers(); combobox.TextChanged += new EventHandler(SomeAction); Button.Click += new ImageClickEventHandler(Button_ClickAction); Lookup.LookupResultValueChanged += new EventHandler(Lookup_ChangeAction); Picklist.PickListValueChanged += new EventHandler(Picklist_ChangeAction); }
Where it takes the format control.SomethingChanged += new EventHandler(XXYour functionXX);
It probably isn't necessary to stick this in the "protected override void OnWireEventHandlers()" function either, especially since this may not be called in a custom smartpart. It should be sufficient to set the event you want on the Page_Load or similar.
Out of interest, if you get this working, let me know! |
|
|
|
Re: Modifying a Form on-the-fly (i.e. visibility)
Posted: 02 Mar 09 10:10 AM
|
Already had a crack at that one last week. The only way I could get it to work was to hack the += new EventHandler directly into the page from within visual studio AFTER I had built in SLX. Obviously not ideal as every time I rebuild, this change gets wiped out. If I was gonna go down this route I would probably try to build an entirely custom smart part from scratch so that I had total control over layout and functionality, but this is a hassle Im trying to avoid. (Adding SLX lookups and picklists into a total custom smartpart made my brain hurt ) |
|
|
|
Re: Modifying a Form on-the-fly (i.e. visibility)
Posted: 02 Mar 09 10:58 AM
|
It depends where you're "hacking" it on.
You could always lie to SLX and add an Load action like below:
}
protected void newAction() { actions...
Whatever you do, don't close the new function, as SLX will do that automatically for you, because it assumes it is closing off the load action.
This way you can add a Page_Load event onto the page.
Alternatively, the best way I have found is to do as much as you can in AA and then modify the code in Visual Studio and re-import as a custom, that way most of the hard stuff is done for you. |
|
|
|
Re: Modifying a Form on-the-fly (i.e. visibility)
Posted: 03 Mar 09 8:29 AM
|
Well I've found a way to do this in 7.2 App Architect which works, for me at least.
Instead of putting the 7 controls I need to show/hide on the form directly, I added in 7 seperate control containers, and put one of my 7 controls into each control container. Then I set the control container visble/invisible as needed, instead of playing with the actual controls themselves. This does relocate the controls when they are made visible.
Hopefully that may be of some use to you... Cheers, Mark |
|
|
|
Re: Modifying a Form on-the-fly (i.e. visibility)
Posted: 06 Nov 10 10:56 AM
|
I know that this thread is quite old now, but what I am doing is directly relevant, so I thought I'd tag something on the end.
I'm having fun trying to hide form controls too - in an external C# assembly.
Hiding the control works well enough, but not the label, for reasons already mentioned. However, if I try to hide the label using something like the following
form.fieldname_lbl.Visible = false;
I get an error in Visual Studio:
'Sage.Form.Interfaces.IAccountDetails' does not contain a definition for 'fieldname_lbl' and no extension method 'fieldname_lbl' accepting a first argument of type 'Sage.Form.Interfaces.IAccountDetails' could be found (are you missing a using directive or an assembly reference?)
Is there any way round this, other than putting the control in some sort of container and hiding that (this stuffs up my control's alignment, so I'd rather not)?
Thanks. |
|
|
| |
|