Hi,
I'm exploring Infragistics windows forms controls for a while. I'm trying to write a common code for setting controls' properties programatically. For that I need to know the type of control in the collection. So how can I find the base class for infragistics controls and a method to get the type of control from the collection?
I'm not quite sure what you're trying to accomplish. Most, if not all, of the control in the Windows Forms suite derive from UltraControlBase, so you could check to see if a control is of that type, but I don't really know what kind of appearances that you're trying to set. Also, if you're trying to set several appearance-related properties, you might want to take a look at AppStyling and AppStylist, since you can load an ISL file that will apply to all of the controls in your application.
-Matt
Hi, Matt
Thanks a lot for your reply. Let me give in brief what I am trying to do.
I'm having multiple win forms containing the textboxes. I am trying to use the UltraTextEditor. I have written a common functions that handle the GotFocus and LostFocus events for some of the controls in each form(e.g. text boxes and combo boxes). I am passing the form name and control name as arguments to the function. Within the function code i'm checking the the type of control that has been passed as argument and if it is of type text box or combo box then I set few properties for that control. With the windows default controls the code works very fine. I am having problem with the ultraTextEditor and UltraComboEditor, as I can not pass the base class for the infragistic controls. But I found the turn arround and now my function can find out the type of control. Now the problem is that the GotFocus and LostFocus events are fired inconsistantly. When the textEditor has focus in it both GotFoucs and LostFocus are fired same time. If focus is moved from texteditor using tab key again the GotFocus is fired instead of LostFocus. I'm really struggling to understand this. Is this a kind of BUG in infragistic controls? What is the turn around for this?
-- Yuujin
Matt,
Thanks again for the feedback. I tried using the 'Control' base class in my function and I could get the type of ultratexteditor correctly. So that way my code is working fine. My main concern is the GotFocus and LostFocus events. I'll try on your suggestion.
Yuujin,
I don't think that the GotFocus and LostFocus events are going to be the ones that you will want to use due to the nature of the way that the UltraTextEditor is designed. When it goes into edit mode, the UltraTextEditor uses a .NET TextBox to handle the edit portion, so you the GotFocus and LostFocus events occur due to the shifting of focus between the two controls; perhaps you should look into the AfterEnterEditMode and AfterExitEditMode events. For more information on the order of events, you can read this recent thread.
As for being able to pass around the control, why can't you pass them to your function with a type of UltraControlBase, or even simply Control? You could check the type of the control in your function directly there; I don't see any reason to pass the name of the control itself so that you have to iterate the Controls collection every time you need to get a reference to that control.