C# 中winform的一些属性设置

时间:2023-12-11 21:15:32

1 窗体的大小固定住,不能调整其大小

窗体FormBorderStyle 属性设置为 FixedSingle;

MaximizeBox 属性设置为false;

MinimizeBox  属性设置为  false;

2. 在状态栏中无图标显示

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAABdCAIAAACQFszyAAAI1klEQVR4nO2dO27sNhSGvRJrEbe5W9AWvAruwItQdbvpXaubZjZg5AaBEiDAANMZSDJObqEmAZiCEp9HEiWLD1P/j1N4ZIqSSH1zjijyzMP7+48N1kP5Cf2Sud7e/pT20/dfpT0AwmKEfslcKyB8nNbOELasqptuZnvX1HQJiBAgzFzrICSrmIawa+pKgspa75MChLvK6ZeWVdXj42O13IZpSx5FGyG0/p6GcGzoVdgsQgitkdkvWk+0rKpmvhvTljyQYkG4iiBAuKuMfumaWt36xgdbaUseSashtJ4G+w0Qdk1dVU6MOkQpQpWxn7NddV/LqrppmPivRqgW8zRHR9fol5ZVZqNPtk3akkdS/HC0a9jY8CogMUKTllVkyKK2GxCOJdQh9L26pj7604feL5b3mcEgbclDKTSEgxOzOOiaetzO2t7pDflxarvlCTtZa91003sdVfCEmSv06KjTyLpnkiwBwpCyIVStMftUlrbkkRT0PSEFodYNXVNT4aiO6cT2eQgRjppyR0eHxln4ekpb8kAKOmOGglCLUWvG1Fdhy1Tgqg+lkNsXIFRjPxiY6d33hKpx9G8qyifFKXl4HWDa2uG/cZf7xXxUi13y8CoSwq6pqaHWo2qxX/T2il8SKhJC41XkwQnsMXc0exUKIaQJ/ZK5doYQBoOtNXjC8oV+yVyAsHyhXzIXICxf6JfMBQjLF/olc6WAcHmBb6r368NsnsJecAHCzBV62hq1RPDDELZMVTtUPseN70ThUicUvztzR+35C4efVJRWwSE0pq743uLkTeEy4jkzyhcua255MTy6EDKGhSYZKR6EayYTAsI9RUDYmtEIIEyqaBBqve44SGe5g5G0omKtnuTCvHcsUrRiC7lMVEm5/MldolXGrUlBaCwkMyEk2xAKqEjPhMZD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shNBxn4BQffSC8BhxQwIFHpgxHvlmMJjKTNF3TV3XKmGTDEp7JxyVyWyaAeupHISAsPeA0E3AgawWoRTWE8o8Do9GQksSAzoThJHFxbw5jGpVmgxiFMEemCGOXrJWQziRgANZLQIpWjgKJRMFIZSRAGH5AoSZCxCWL0CYuQBh+QKEmWt/CLftCIMd1vaH8Ms3DsvK3uEJI4qtFyAs3wBhTDHG/lsjQHgIA4QxJSD84SdAeBQDhDH1OSC8cH56SX9rztvpzi9nr435GyCMKQHhP36KBOGFD5K37y4QPr3a1Vr2fOW2roBQ/cSS+p0pzEDbVQLCv/0UA8KLBsnpzp/3g1BgdntdLnbhw3FXWakQjsLK+lASEL77KTyEL/x2508UFYAQEJYqAeFffortCQ0IX4kQ8aJFjs8OZqqqM+d3/uT8V9ZpkWlD+MJvToQsg1t5aMWbKH9VG90Am6xTFaa+iTKDEOktdpOA8I9RD5Tkf6M8E56NO1vBdlX3rvCKFx2e87DL0+tY8sxv96GAZM+C0K2ThPB0HZEYjyJ2sbzlAOGZc6220127lrNGrFunVfgzQIj0FrtIQPi7JotA/V/xRkcHPzM6vYt5W59elHOzGRjxeL7y0wu/3PmT3MX1hFadExB+ofyecG76Xqc7v1xtiqxwVP8450tTm7cnpD4hvcVKCQh/MyUJtLbHfkUh40lPCEUZ8YfC76yeM7dA+MJv0uU6DlD4LnlcfredKg3hRJ3lQYj0Fj4SEHaOHh4e3I1RBmbMRz4ZebrA2OHoSNrTK7/dBy8q/pbFtkBo1izD0ZP5IGcBpj/mSX+udifr/PQQIr3FRgkIf/FTDE+oB2nke0IdGHdg5ss3EwPtec96T+gfjgp3xzm/XZXXUi8Vr6qYfsLilGSMap0kWecnhhDpLT4gAeHPfsK0taMYBSEUSgLC734KBSEMBttgu0GY/Fsf5ho8YUxtW8q050+jJb/hYK4Bwpjatqh3TwhhMNham4Lwf6dCGfGXrLihAAAAAElFTkSuQmCC" alt="" />

设置为fase即可。

3. 设置窗体的启动位置

方法1, 用代码控制

this.Location = new System.Drawing.Point(xPos, yPos);

方法2 在窗体的设计模式下手动设置

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAASEAAAB4CAIAAAAyidPHAAALbElEQVR4nO2dMW7sNhCG3b5LrA7xGl9BV3in0A18CFWvc+9anRtfIEGCQAgQwIDrIN4khZoXQCkkksPhSKKWlJaU/g8s1lyKWu/wFynuzOjhev0XBQVlu/KwqnUH0gN2SRxBYz8eH1FQTlXuoDHMYxkBuwQCjYEFYJdA9tPYRfHj8fFicweNtXVZlHW73wnzBRoLZFeNiaec1lhbl0XVbPO5oDFvuF2aSl8czTfY1mVRDJXGZGKlQFuXYzNq76Yq9IkK/YZvnwlxH43p192uGttStMeF2YUOfTXQm6qgehikJ1ZKENksacy7z5SAxsACXGP1OLDbuhxHeVNpeQzCKOtWrpyhrcuiYBormLnW9pkGe2uM3Y91qzVmrmS2AUz9+L3zRQU5sKxbq2+xz6Yqyrqu+KLofHC7kC92+FraujQrNyUDsXLuNJLG7NlSPlG0/3Mz8prHmoquD5qKLiFsGbR1pf42zUiH5uVcn+S486psRmNqGivMV6ikIlbOnWZWY0NXq/tMg6w01lT2UFcNeL15256dJI1N9Wm90dYlNMYZNFA15sVQO0wvYuXcaaY1M3+ikH9tH7LaVxT0oC6kTALmXoF246kxfcsOjXUd15i+HTMjfriWsdsksXLuNFxjTaVez58o4n+6ESn/PuaxVhz/MCu8cRAQgbR1uW6taPqExrrO0Ziws0dWj2bVIFbKWH0qFbETre0zIVL28zA/m+il/+Seh/r2qZyGZmVVUWVdVu15tLp3aGyA/JZFFwDqR7P5SnK9o4gaoyey7tKEE6VNyhoDSRDRLnS9cR6gMbBAPLucdH8WGgMLwC6BQGNgAdglkLQ0hoJyvLL1gEccNArK7vPYTNn0o4DbgF0SBxrLHtglcaCx7IFdEkfwpXLZXGN3+WHmKL8GQWOJI/gEM+b9FSWXGSvEwYs9hrtxCCIukYfU2PifetjAvyW4HVljF+/YlrLknoLG53DLz70S6iTU1uWh/IWujr+i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7pvf/4CRq7RWNjqL/9HMTSjs10XISVF29jP+GexnQ6AZ68k9No7C8/Is9jumZkkN9L/+Gs/QYBvPV9/2neHdpPacx024+z5dfv/bef7MqX/qPvn9hnUJUz/bz1/bPq6mZVJ6axqmLRzlaNGJZixGnVT2pM6uQ0GvtT8SCh341xP/bKx+tXNi+9q4nu1TQbbrqexPbSWvGNDv1XrijzYUiN6ZNUyv0MwnvnJ82oSBqrGx2mOcarWFrhrVv1kjzItDABgaLGpE5Oo7E/CExg9K1o+4rjfPIuaOarO9s4DZjGNONYf1VTotP+jTZb1NhsP7oTOpHmUkSNtSrdgAoJk5d5F5aKg+TDWdKY1MlpNPa7jRYYq4+8d6/XjWx8j1OHKABJY3yIS9qgbQZZPr/cojE9Tx5RY2Txp6cz88pNpzOrMdp8ppPTaKx1eHh4cCtj7Hm8mz/1SDXjmwzrYTa7RWPuGk/d6T3bN3ir14rqsx1VYzr2md1X8bR88xqz77v0rZfcyWk09psfEeYxug7UOhkr1R7GuJfwPjmPsfbiEBf3Kp7eVRW5m3pifXrueRxSY1ZiD2G7ohhyJi5ojGp1qZPTaOxXPw7n53HWck3Hz4NwbI394gc0dpACjUXEU2M/+wGNHaRAYxFBbAuKUKCxiNw/RhMF5djl/rkG9rmWgFXALhG5f86c6KcH4cAuEYHGgADsEpH9NIaCctqyh8ZmyuruV2V3xsOTbiKZeayp8CQkif8BP0dEMfyg7ZQAAAAASUVORK5CYII=" alt="" />

4. 判断窗体是否已经存在

if (ProgressForm.Created == true)
{
ProgressForm.Close();
}

参考文章

怎样能使winform窗体的大小固定住,不能调整其大小