C1Theme and readonly textboxes

Posted by: wknauf on 12 May 2019, 10:27 pm EST

    • Post Options:
    • Link

    Posted 12 May 2019, 10:27 pm EST

    Hi C1,

    see attached sample: when using the theme “VS2013Red”, textboxes with “ReadOnly = false” have the same appearance as regular textboxes. Same for theme “Office2016Black”.

    Is there any chance to change this? We prefer to make textboxes readonly instead of disabled, because here you have the chance to e.g. click it and scroll longer texts.

    Bonus: in my sample, the theme “Office2016Black” changes the forecolor of the buttons in a way that the texts are unreadable.

    Best regards

    Wolfgang

    ThemeTest.zip

  • Posted 17 May 2019, 1:13 am EST

    Hello,

    I am able to reproduce the issue at my end. I have escalated the issue to our development team(380262, 380263) and will inform you once I get any information from them.

    Thanks,

    Mohit

  • Posted 22 December 2019, 10:23 pm EST

    Hello,

    Bonus: in my sample, the theme “Office2016Black” changes the forecolor of the buttons in a way that the texts are unreadable.

    I am glad to tell you that this issue has been fixed in the latest build of C1. You can download the same from the following link:

    http://prerelease.componentone.com/dotnet40/c1winforms/2019-t3/C1WinForms.4_4.0.20193.393.zip

    Thanks,

    Mohit

  • Posted 1 January 2020, 7:00 pm EST

    Thanks, I can confirm that the button texts for “Office2016Black” are fine now.

    The issue “read only textbox” is still open.

    Best regards

    Wolfgang

  • Posted 5 January 2020, 10:33 pm EST

    Hello Wolfgang,

    The issue “read only textbox” is still open.

    As per our development team, it is a limitation of C1Theme.

    Thanks,

    Mohit

  • Posted 6 January 2020, 12:23 am EST

    Hi Mohit,

    I need a solution for this. This is a blocker for upgrading to the new ribbon, where we have to move from VisualStyles to C1Theme. Currently, C1Theme is an optional feature.

    We use read only textboxes a lot, and it would be bad if those have the same appearance as normal textboxes.

    Please think about this issue.

    Best regards

    Wolfgang

  • Posted 6 January 2020, 12:27 am EST

    Hello Wolfgang,

    I have forwarded your concern to our development team and will inform you once I get any update from them.

    Thanks,

    Mohit

  • Posted 12 January 2020, 10:26 pm EST

    Hello,

    As per dev reply:

    It is a limitation. The MS TextBox.BackColor property returns the current color value (this is different for the Normal and ReadOnly state). If the property is not set (default value) then the TextBox control itself automatically changes the value of the property depending on the ReadOnly state. But applying the theme we manually change the value of the BackColor property. And after that, the BackColor property does not change automatically, but always returns the value set manually (the same in Normal and ReadOnly state). This is the behavior of the MS TextBox control and we can’t do anything about it. So, again, this is a limitation, and it is not related to the theme, but to the behavior of the MS TextBox control.

    They managed to add a small improvement to the C1Themes. Now the BackColor will not be set if it matches the default value in the Normal state. But this fix will not work if the default and themed colors are different. This fix at least will help to remove this problem for most of our themes, but not for all of them. For example, in dark themes, the old behavior will remain.

    The improvement will be available in the 2020 v1.

    Thanks,

    Mohit

  • Posted 13 January 2020, 10:59 pm EST

    Hi Mohit,

    I tried to implement a workaround, see attached sample: I subclassed TextBox and prevent BackColor changes if it is “ReadOnly”. The themed BackColor is stored in a member variable and reset if “ReadOnly” is reset.

    ThemeTest.zip

    What do you think of this approach? Or did I miss something?

    If this is a good workaround, I might add it to our custom code. I will wait for the improvements in the next version and check whether the workaround is necessary.

    An other workaround would be to prevent theming of ReadOnly controls by implementing “IC1Themeable”. This will work if the TextBox is ReadOnly when the theme is applied and will not stye readonly.

    Best regards

    Wolfgang

  • Posted 15 January 2020, 9:37 pm EST

    Hello Wolfgang,

    I have forwarded your sample to our development team and will inform you once I get any update from them.

    Thanks,

    Mohit

  • Posted 20 January 2020, 12:14 am EST

    Hello,

    Reply from Dev,

    The solution looks right, but it seems too complicated to him.

    The problem of this approach is that in some themes, the controls may look ugly in the read-only state (much different from the rest of the themed controls). Although I can’t say for sure if it will be that bad. This will not happen if you replaces the TextBoxes with C1TextBox controls.

    Could you please tell the reason why do not you replace the textbox with C1textobx? It is much easier than adding a custom control.

    Another option is to create own ReadOnly BackColor using the original color and darken/lighten it (see ThemeTest2.zip)

    Thanks,

    MohitThemeTest2.zip

  • Posted 21 January 2020, 2:13 am EST

    Hi Mohit,

    I never thought about using C1TextBox - did not see a benefit up to now ;-). Unfortunately, we have a large app with a lot of controls… Give me a few days to think about this option ;-).

    But it seems that e.g. the “Office2016xyz” themes don’t make a difference beetween editable, readonly and disabled C1TextBox controls ==> thus bringing me back to the initial problem, and the situation is even worse as disabled textboxes are not different to normal boxes.

    When playing around with themes, I noticed two problems:

    a) C1ThemeDesigner 4.5.2 app (version .393) crashes when opening any theme and clicking on the “C1Ribbon” item in the “Theme tree”. Before the crash, there is an error “Your trial period has expired”.

    Exception message:

    System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---> System.ComponentModel.LicenseException: Für den Typ C1.Win.Ribbon.C1StatusBar kann keine gültige Lizenz erteilt werden. Weitere Informationen erhalten Sie vom Hersteller der Komponente.
    

    …which means that the license for C1StatusBar is invalid.

    b) see attached sample: the themes “Office2016xyz” cause WinForms labels to get a strange background - not the default background of the form. Is this intended? It looks strange at least, and a “C1Label” does not show this behavior.

    C1TextBoxTest.zip

    Best regards

    Wolfgang

  • Posted 22 January 2020, 1:14 am EST

    Hello,

    I am discussing this with our development team. Also, I am not able to replicate your first. Could you please tell me if I am missing at my end.

    Thanks,

    Mohit

  • Posted 22 January 2020, 7:37 pm EST

    Hi Mohit,

    I uploaded a video showing the crash: https://www.hg-online.de/downloads/themedesigner.zip

    Hope this helps to reproduce it. The “C:\Program Files (x86)\ComponentOne\Apps\v4.5.2” directory was extracted from the prerelease zip fpr .393.

    Best regards

    Wolfgang

  • Posted 23 January 2020, 6:11 pm EST

    Hello,

    I think the file is corrupted. Could you please attach it again.

    Thanks,

    Mohit

  • Posted 23 January 2020, 8:30 pm EST

    Sorry, fixed it.

    It seems the broken file might be cached e.g. in your local browser, at least this happened to me and firefox. If this is the case, open e.g. a private window and try the download there.

    Best regards

    Wolfgang

  • Posted 28 January 2020, 2:06 am EST

    Hello,

    Thanks for the video. I am able to reproduce the issue at my end. I have escalated the issue to our development team (418652)and will inform you once I get any information from them.

    Thanks,

  • Posted 3 February 2020, 2:47 pm EST

    Hello Wolfgang,

    Regarding C1 Textbox issue.

    It is a bug which is fixed internally and will be merged in 2020V1 hotfix

    Regarding ThemeDesigner issue

    It is also fixed internally and will be merged in the next release.

    Regarding Label issue:

    As per developer, This is due to the theme changes the forecolor and backcolor and they stop being inherited from the parent.

    It would be better not to apply the theme (not to change the forecolor and backcolor) to the label at all, so that it inherits properties from the parent.

    As a workaround, You can use C1Label instead or don’t apply the theme to the MS label to allow it to inherit properties.

    Thanks,

    Mohit

  • Posted 3 February 2020, 7:43 pm EST

    Hi Mohit,

    thanks, this sounds promising. I will await a fix and test it again, and then I will think again about switching to C1TextBox ;-).

    Just to be sure: the “background of Label with Office2016xyz theme” issue will be fixed?

    Best regards

    Wolfgang

  • Posted 4 February 2020, 11:06 pm EST

    Hello,

    It is also fixed internally and will be merged in the next release.

    Please use the following build to have this fix:

    http://prerelease.componentone.com/hotfixes/dotnet/C1WinForms.4_4.0.20193.405.zip

    Just to be sure: the “background of Label with Office2016xyz theme” issue will be fixed?

    Sorry to mention that we can’t fix this, You need to use C1Label instead of MSLabel.

    Thanks,

    Mohit

  • Posted 5 February 2020, 9:37 pm EST

    Hi Mohit,

    I can confirm that the ThemeDesigner issue is fixed.

    The “readonly C1TextBox” issue is still open, but you wrote above that it will be part of the next major release.

    About the Label problem: sorry, I don’t like the idea to migrate all Labels to C1Label :-(. We have hundreds of labels in our application. Though it might be possible to “search&replace”, I fear that problems might arise because of this change (bugs in C1Label, performance issues, bugs in our code) …

    Currently, my love for C1Themes cools down a bit :wink: - I accepted that we have to switch to it when we migrate to the new ribbon und thus have to change all TextBox controls to C1TextBox. But now the impact seems much higher. Could your developers please try to find a solution for the label issue?

    All of your other customers will also be forced to change “Label” to “C1Label”.

    It might even happen that a customer uses any non-C1-third party component which contains labels - here it will not be possible to change the labels.

    Best regards

    Wolfgang

  • Posted 6 February 2020, 7:52 pm EST

    Hello Wolfgang,

    Sorry for the inconvenience caused to you.

    I have forwarded this to our development team and will inform you once I got a reply from them.

    Thanks,

    Mohit

  • Posted 10 February 2020, 12:47 am EST

    Hello,

    As a workaround, you can exclude the labels from the theme application using a predicate:

    C1ThemeController.ApplyThemeToControlTree(this, theme, (control) => !(control is Label));
    

    This will prevent the theme from being applied to Label controls. As a result, the label will inherit property values (ForeColor, BackColor, Font) from its container.

    I think it will fulfill your requirement.

    Request to please confirm if the workaround is suitable for you.

    Thanks,

    Mohit

  • Posted 10 February 2020, 9:31 pm EST - Updated 3 October 2022, 2:29 pm EST

    Hi Mohit,

    this is an easy change to our code, thanks for the suggestion.

    But after doing a bit more testing, I am confused about the “Office2016xyz” themes, e.g. “Office2016Green”: a C1RibbonForm has e.g. green background. But as soon as a Panel or a GroupBox is placed on it, this control has another background. The same applies if a dialog form is shown, see screenshot “office2016green.png”.

    Is it intended that the empty part of the ribbon has another back color than e.g. group boxes or tab controls? If yes: for group boxes this does not look well.

    And is it intended that all dialog forms also have another back color than the ribbon?

    If it is intended, then the Label/C1Label problem will never arise in our “real” app, because we never have an empty area on ribbon forms - they all contain a bunch of container controls.

    Best regards

    Wolfgang

  • Posted 11 February 2020, 9:09 pm EST

    Hello,

    I have forwarded this to our development team and will inform you once I got a reply from them.

    Thanks,

    Mohit

  • Posted 12 February 2020, 10:50 pm EST

    Hello,

    If it is intended, then the Label/C1Label problem will never arise in our “real” app, because we never have an empty area on ribbon forms - they all contain a bunch of container controls.

    It is intended for the old version of C1RibbonForm. But this will work for both versions of C1RibbonForm.

    But in the new C1Ribbon and C1RibbonForm there should be no such problems. The new C1RibbonForm must have the same color as the dialogs and containers in Office2016 themes. In addition, the new ribbon looks more modern and It also has a backstage menu and a simplified view. What is not in the old (classic) ribbon.

    You can try the new C1Ribbon and C1RibbonForm instead of the old one (classic). Or use containers.

    Actually, the problem is that the old C1Ribbon doesn’t support different colors for the form content and form title. This is true only for the old C1Ribbon (Ribbon classic). So, if the form header color is green, then the form content color will also be green (what doesn’t match the color of other containers and dialogs). The old C1Riboon didn’t support many of the visual features that are relevant today. It would take too many changes to fix this, so it was easier to create a new C1Ribbon control, what we have did.

    Note:

    new ribbon form has a namespace “C1.Win.Ribbon”

    old (classic) ribbon form has a namespace “C1.Win.C1Ribbon”

    Thanks,

    Mohit

  • Posted 12 February 2020, 11:02 pm EST

    Hi Mohit,

    thanks for the info.

    So, we don’t have to care for labels because we always have container controls on the form ;-).

    We will migrate to the new ribbon when the DPI awareness issue is fixed, which has no schedule up to now.

    Now awaiting the promised fix the readonly textboxes ;-).

    Best regards

    Wolfgang

  • Posted 13 April 2020, 7:33 pm EST

    Hi,

    I checked with build .416, and I don’t see a difference for the back color.

    Attached is a new version of the sample (two different projects for old/new ribbon):

    MSTextBox:

    ReadOnly and disabled: backcolor is a very light gray (240/240/240), compared to normal textbox (white, 255/255/255). This is a visual difference, but it is very small. Is there any chance to improve this?

    C1TextBox:

    ReadOnly and disabled: still has the same backcolor “white” as a normal C1TextBox.

    I expect them to have different back colors.

    C1TextBoxTest_416.zip

    Best regards

    Wolfgang

  • Posted 15 April 2020, 4:11 am EST

    Hello,

    As I said here, C1Textbox issue is fixed in the 2020V1 hotfix:

    https://www.grapecity.com/forums/winforms-edition/c1theme-and-readonly-textb#hello-wolfgang-regarding-c

    Could you please wait for the hotfix of the 2020 V1.

    Sorry for the inconvenience caused to you.

    Thanks,

    Mohit

  • Posted 15 April 2020, 9:34 pm EST

    So the 4.5.20201.416 version was not the 2020V1 hotfix? Confusing ;-).

    Best regards

    Wolfgang

  • Posted 19 April 2020, 6:22 am EST

    Hello,

    It is the initial version of the 2020V1. I will notify you when hotfix version of 2020V1 is released.

    Thanks,

    Mohit

  • Posted 24 May 2020, 10:49 pm EST

    Tested with .424 (which is hopefully the hotfix version that you mentioned above): the WinForms TextBox works now great for the theme “VS2013Read”, which was my initial issue. So, current I think I don’t have to migrate to C1TextBox.

    As you wrote above, this does not work for dark themes (“Office2016Black”), but here I could not even define how to display a readonly textbox in this theme…

    But it seems the C1TextBox still has issues when e.g. the theme “Office2016Green” is used - there is no difference beetween normal and readonly textbox.

    Best regards

    Wolfgang

  • Posted 25 May 2020, 11:18 pm EST

    Hello,

    I have checked that issue is still reproducible with the .424. However, our QA team confirmed that this issue has been fixed in .425. Could you please wait for the next build.

    I am very sorry for the inconvenience caused to you.

    Thanks,

    Mohit

  • Posted 25 August 2020, 8:48 pm EST

    Hi Mohit,

    the C1TextBox issue (with theme “Office2016Green” there is no difference beetween normal and readonly textbox) is still present in .438.

    Best regards

    Wolfgang

  • Posted 9 September 2020, 1:43 am EST

    Hello,

    I have escalated this to our development team(461886) and will inform you once I get any information from them.

    Thanks,

    Mohit

  • Posted 5 December 2020, 6:01 pm EST

    Hi,

    The issue has been fixed in the latest version i.e. 2020V3.468. Please upgrade your controls to get rid of this issue.



    Note:
    As per the developers, it’s better to enter the text to distinguish between the ReadOnly textbox and the normal textbox.

    Regards,

    Prabhat Sharma.

  • Posted 10 December 2020, 1:39 am EST

    Thanks, I can confirm that it works now.

    Best regards

    Wolfgang

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels