在 vb.net 中设置每个表单的背景色 [英] Set backgroundcolor of every form in vb.net

查看:82
本文介绍了在 vb.net 中设置每个表单的背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置 vb.net (fw 4.7.2) 项目中存在的每个表单的背景颜色?
是的,我可以

How can I set the BackColor of every form that exists in my vb.net (fw 4.7.2) project?
And yes, I could do

Form1.BackColor = ...  
Form2.BackColor = ...
......

但是那样就太乱了.

推荐答案

  • 在设计器中打开一个表单,任何表单都无所谓
  • 点击表单背景
  • 在属性网格的顶部,转到(应用程序设置),然后单击(属性绑定) 中的点按钮,在属性列表中找到 BackColor,点击旁边的下拉菜单,然后点击底部的新建
  • 调用您的设置 ThemeColor,为浅色主题选择您想要的颜色,例如白色
  • 一切正常
  • 打开另一个表单的设计器,再次转到应用程序设置/属性绑定.这次不要点击新建,只需将 BackColor 绑定到现有的 ThemeColor 设置
  • 对您应用中的所有表单重复
    • Open one of your forms in the designer, any form, doesn't matter
    • Click the form background
    • In the property grid, at the top, go to (Application Settings) then click the dots button in (Property Binding), find BackColor in the list of proeprties, click the dropdown next to it and click New at the bottom
    • Call your setting ThemeColor, pick the color you want for the light theme, such as White
    • OK everything
    • Open the designer for another form, go Application Settings/Property Binding again. This time don't click New, just bind BackColor to the existing ThemeColor setting
    • Repeat for all forms in your app
      • 在设置"中添加一个按钮表单(或您想为主题提供切换的任何地方),并在其点击处理程序中写入:

      • Add a button to the "Settings" form (or wherever you want to offer a toggle for the theme), and in its click handler write:

      My.Settings.ThemeColor = Color.White

      My.Settings.ThemeColor = Color.White

      向表单中添加另一个按钮,使其点击处理程序设置为 Color.Black

      Add another button to the form, make its click handler set Color.Black

      • 运行应用程序.打开一个或多个表单,包括设置表单.单击按钮之一更改设置.所有表格都会变色

      这篇关于在 vb.net 中设置每个表单的背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆