Values of the UI controls not being set at runtime

I have a base class library which contains all the UI controls with extended capabilities.

Ex: XTextBox <---derived from------ TextBox XPanel <---derived from------ Panel XLabel <---derived from------ Label

I use this library in my client application for rendering the controls on the UI.

I have an AppConfig file which determines the font/color for my client application.

Now the issue am facing is when i set the font values to the controls in my base class library.

For ex: The backcolor of the XTextBox is read from a utility class CUtility which reads the color information from an exe.Config file

this.BackColor = CUtility.GetBackColor(); //this represents the XTextBox control.

Many a times the backcolor is not set for some UI Controls in the runtime(Ex: Panels and for some UI Controls)

However these colors are set if i do it from the UI designer.

Any ideas where am doing wrong.

Regards

--------------Solutions-------------

The BackColor property is special, it is an 'ambient' property. If it was never assigned then it will automatically get the value of the parent's BackColor. That's very nice, it automatically makes all the child control background colors right when you change, say, the background color of the form. Other properties that behave this way are ForeColor, Cursor and Font.

Sounds like this is your problem. Start by looking at the BackColor property of the controls that don't color correctly in the Properties window. If it is shown in bold then right-click it and choose Reset. Looking at the InitializeComponent() method and searching for BackColor assignments is a quick way to find them all.

Next, check if your custom controls assign the BackColor property explicitly.

check CUtility.GetBackColor() is returning value while set to panel

Are you using Winforms or Web contros ?

Category:c# Time:2010-09-08 Views:0
Tags: c# winforms

Related post

  • How to dock a control inside a panel at runtime on windows forms? 2009-07-27

    I am designing a simple user interface using winforms. In the designer I have a panel on the form and would like to add a datagridview control into the panel at runtime and set the dock property of the datagridview to 'Fill' so that it fills the pane

  • Specifying a unique control name when adding at runtime (like the VS IDE) 2010-04-14

    I have a basic IDE for a user control i am building. It allows me to add labels to a panel and move them around, like a very basic form designer. When I add the controls to the panel at runtime, I'd like to give the control a unique name string like

  • How to add a User Control to a window at runtime? 2010-11-22

    I need to add a User Control to a window at runtime. Now my problem is that i need to instantiate the window first and then add the User Control to that window. After all this the window only will be shown My thoughts was this: Create the instance of

  • Adding a Control (or Controls) in VB.NET at runtime 2011-03-30

    This question is about VB.NET. I'm quite a novice on this one, so please forgive me if you feel that this question is nothing short of crazy or whatever. Anyway, I've been a creating a simple Windows addressbook Form application. We all know for a fa

  • WinForms - Programmatically adding lots of controls to a Panel at runtime 2009-09-26

    I need to be able to add several hundred instances of a custom control (UserControl) to a panel at once. When I do this using Controls.AddRange(), it hangs for a very long time. Is there something I need to do that will decrease the amount of time th

  • How to get all controls from a form at runtime in C#? 2009-11-30

    Is there a simple way to get all controls that contains the property ".Text"? I'm able to get all "top level" controls, but my code doesn't find sub controls like menu items on all levels, etc. I also tried "ctrl.HasChildren". How do I do this in Win

  • Adding controls to TabItems dynamically at runtime in C# 2010-01-10

    So, here is my issue, im working in a Wpf application, so i dont have all of the standard windows form controls.. so im attempting to use a windowsformshost, to hold a webbrowser inside of a tabitem. So here is what i have: Tab t = new Tab(); Browser

  • Changing properties of controls that were added at runtime 2010-04-18

    I have a form in which several buttons are added at runtime via a 'for' method public Form() { for (int i = 0 ... ) Button b = new Button() b.text = (string) i ; etc.. etc.. } . now i wish to change the text property of the buttons on a certain event

  • Adding control to a panel at runtime 2010-12-16

    I'd like to add a control A (that exists on a page) to a Footer user control's panel. If I create the control A dynamically and add it, I don't have issues. But I would like to avoid adding this dynamically. So, I defined control A in the aspx page a

  • How to add compound control to a layout at runtime? 2011-08-12

    I created a compound control using xml, and am able to re-use it by placing in other xml layouts. But i want to add it at runtime using java code. I tried the following code but only the textview is visible and the compound-control is not shown... I

  • Events for controls that are created at runtime 2011-09-19

    Ok so i have a DetailsView like so... <asp:DetailsView DataSourceID="sqldsNewItem" CssClass="marginLeftRightBottom10px" DefaultMode="Insert" FieldHeaderStyle-CssClass="dwHeader" GridLines="None" ID="dwNewItem" runat="server"> <Fields>

  • Creating a WPF control that loads XAML in runtime 2011-10-06

    I'm working on a WPF map application that when it loads it looks at a SQL database and according to the map that is specified there loads it as a XAML drawing (using paths on a canvas). I wanted to create those XAML maps as DLL's that when the app la

  • Disposing of controls in a layout at runtime on android application 2012-03-13

    I need to reset a layout or dispose some of the controls on that layout according to some certain cases. But I couldn't find a way to do so. Do you have an idea about how to do? Thanks in advance. --------------Solutions------------- Maybe you can ju

  • How to get controls from Grid.Row at runtime? 2010-11-28

    I have a Grid with 3 Rectangles in it. I need to get a reference to the rectangle that has Grid.Row == 3 at runtime. How can I get access to it? Thanks --------------Solutions------------- var target = myGrid.Children .Cast<UIElement>() // make

  • Binding a silder control to a RotateTransform at runtime in Silverlight 4? 2011-01-29

    I know you can do this dynamically in XAML, but how can you do this in code? I have a rectangle that is drawn by the user, and I want to attach a slider to the rotatetransform, via code. Help? --------------Solutions------------- It's strange, that a

  • Linq to Entities control table name resolution at runtime 2011-02-12

    I've implemented a content management system that deals with a certain kind of object, and now the client has introduced another kind of object, whose structure and behavior is exactly the same, but separate. They want to be able to switch modes, whe

  • Iterating form controls that are created at runtime 2012-04-03

    I create form dynamically on the client side. I want to iterate it, but know how many fields were created only in client runtime. based on http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspxIn ASP.net I want to add some data to the mod

  • How to change font properties of a control (e.g. label) at runtime 2013-12-03

    I've got the need to change the font properties of the text in a Label and in an Item of a ListView during runtime. I thought it was easy, writing: label1->font->Bold=true; But its not possible, because 'Bold' has just got a get() but no set()

  • What is the best way to clear all controls on a form C#? 2008-11-18

    I do remember seeing someone ask something along these lines a while ago but I did a search and couldn't find anything. I'm trying to come up with the cleanest way to clear all the controls on a form back to there defaults. eg Clear textboxs, uncheck

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 3.156 (s). 13 q(s)