Controls within user control via code - user-controls

I have a user control(say control1) with a label(say label1) inside.
I wish to call user control from a form(say form1) with code which will be implemented dynamically with if-else condition.
So i want to call user control from FORM1 and access label1 of the user control via code.

Related

Creating a log-in system using Tkinter

I'm having a trouble while implementing a log-in system in an interface I'm creating:
I want it to have two type of user: admin and user, so depending on what you choose you input your credentials and then if they're correct the system opens either the admin interface or the user interface.
My problem is that given the knowledge I have right now, I have to have a "mother window" while executing tkinter which is the first windows that opens when you run the program, in this case that mother window would be the log-in window, the thing is that if I close that log-in window once the user inputs his/her credentials, then the whole program doesn't work.
Is there a solution for this?
The simplest solution is to create two functions or two classes, one for the login window and one for the main window. Have these functions or classes return a single frame that contains everything needed for that part of the code.
Then, call the first function or class to login in, then destroy it and call the second function or class. When you destroy a frame, all of its children are also automatically destroyed.

Can I grab and populate a screen made by a programmatically triggered button push?

Am I able to grab a screen that is created by a programmatically triggered button push call and populate it with values?
My specific example is that I want to grab the new e-mail screen that is made when I execute this code:
CRCommunicationDraft graph = PXGraph.CreateInstance<CRCommunicationDraft>();
graph.AddNew.PressButton();
I want to grab the screen created after AddNew.PressButton() is executed. Is there any way to do this?
For this specific case, I think is answered here:
How can I open an editable, sendable e-mail screen with prepopoulated values?
For most cases you want to:
Override the Action Handler of the button. You can use OVERRIDE METHOD button of customization editor for that. In your case override the AddNew action event handler.
Create a new graph instance for your target screen, here it is CREmailActivityMaint.
Assign to or insert a record into the current DataView of that graph, in your case use CREmailActivityMaint.Message DataView.
Redirect to the screen, using PXRedirectHelper class.

Design Approach for Custom Control in C#

Am Creating a user control which will have a button, textbox and label. And i have created some delegates for Button and Textbox.
Now, i need some properties like assign text, visibility and some
other at runtime. For this whether shall i creating a Button itself
as property (or) creating each property for text and visibility. Which one is a good approach ?
I have created some custom events for Button. Now i have to avoid
the default events which is like OnClick e.t.c. Is it possible ?

User control in a page with a page level grid

I have an aspx page with a Telerik RadGrid right on the page. Then there is a user control embedded in the page with a seperate TeleRik Grid. When a row is dragged from the page level grid to the user control grid I am having trouble finding the UserControl.Grid When using intellisense, the UserControl.Grid does not show up. I need to be able to grab the UserControl.Grid and do some work on it durnig the Row Drop event. Any ideas?
The grid inside the user control should be accessible on the client my its ClientID despite it resides inside a user control (since the user control does not rendering additional html element). On the server you can reference the user control grid by invoking the FindControl(gridId) method for the user control instance.

Methodologies used for designing user controls

I want to able to create reusable user controls within my web app and i'm wondering on how to go about doing so.
Should a user controls properties be
visible to a form that's using it?
What's the best way to go about
loading the controls on the user
control from the form thats using
it? Should there be a public method
within the control that allows you
to load it from an external form or should the user
control be loaded in the page load
event
Is it okay to nest user controls within user controls?
etc...
Thanks for any advice
1) You only need to make properties visible if any page needs to read or modify information on your control. I personally like to keep my user controls as self contained as possible, and keep this to a minimum.
2) I would just rely on the built in page life cycle to render your control, but it is important to note when each of your control's events fire in relation to your pages. You may find that there are times that you need something on your control to render before something on your page does. In this case you will need to rely on the page_init in your control more than the page_load of your control.
3) You technically can nest user controls, but things will get tricky if you need to start reading and writing information (as in your first question) from any of the nested controls. Also, the page life cycle of the nested controls gets even more important. I would avoid this if you can.

Resources