Как убрать рамки в windows form

Полностью убрать рамку формы C# Решение и ответ на вопрос 1717017

ZippoLight

2 / 2 / 0

Регистрация: 15.04.2016

Сообщений: 27

1

Полностью убрать рамку формы

21.04.2016, 09:12. Показов 18458. Ответов 4

Метки нет (Все метки)


Дорогие мастеры, у меня возникла не большой вопрос.

Я на своем форме убрал рамку форма с этим кодом

C#
1
2
3
4
5
6
            // Делаем обычный стиль.
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            // Убираем кнопки свернуть, развернуть, закрыть.
            this.ControlBox = false;
            // Убираем заголовок.
            this.Text = "";

Скрин ->

Но как на скрине остался такая рамка, хочу чтобы его тоже удалить чтобы остался только этот зеленый фон(Зеленый фон просто картинка который закинул с picturebox)

Заранее спасибо.

Миниатюры

Полностью убрать рамку формы
 

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



1



MVK

160 / 148 / 92

Регистрация: 30.03.2011

Сообщений: 569

21.04.2016, 18:06

2

Лучший ответ Сообщение было отмечено ZippoLight как решение

Решение

Сделайте так:

C#
1
this.FormBorderStyle = FormBorderStyle.None;



4



7 / 7 / 3

Регистрация: 19.04.2016

Сообщений: 169

21.04.2016, 18:41

3

Либо можешь поменять свойство FormBorderStyle на None в конструкторе.



2



2 / 2 / 0

Регистрация: 15.04.2016

Сообщений: 27

22.04.2016, 08:32

 [ТС]

4

Спасибо,помогло =)



1



1 / 1 / 0

Регистрация: 16.06.2016

Сообщений: 3

14.11.2016, 17:57

5

Спасибо!



1



I am sharing my code.
form1.cs:-

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BorderExp
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

    }

    private void ExitClick(object sender, EventArgs e)
    {
        Application.Exit();
    }

    private void MaxClick(object sender, EventArgs e)
    {
        if (WindowState ==FormWindowState.Normal)
        {
            this.WindowState = FormWindowState.Maximized;
        }
        else
        {
            this.WindowState = FormWindowState.Normal;
        }
    }

    private void MinClick(object sender, EventArgs e)
    {
        this.WindowState = FormWindowState.Minimized;
       }
    }
    }

Now, the designer:-

namespace BorderExp
 {
   partial class Form1
  {
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows Form Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        this.button1 = new System.Windows.Forms.Button();
        this.button2 = new System.Windows.Forms.Button();
        this.button3 = new System.Windows.Forms.Button();
        this.SuspendLayout();
        // 
        // button1
        // 
        this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
        this.button1.BackColor = System.Drawing.SystemColors.ButtonFace;
        this.button1.BackgroundImage = global::BorderExp.Properties.Resources.blank_1_;
        this.button1.FlatAppearance.BorderSize = 0;
        this.button1.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
        this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
        this.button1.Location = new System.Drawing.Point(376, 1);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(27, 26);
        this.button1.TabIndex = 0;
        this.button1.Text = "X";
        this.button1.UseVisualStyleBackColor = false;
        this.button1.Click += new System.EventHandler(this.ExitClick);
        // 
        // button2
        // 
        this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
        this.button2.BackColor = System.Drawing.SystemColors.ButtonFace;
        this.button2.BackgroundImage = global::BorderExp.Properties.Resources.blank_1_;
        this.button2.FlatAppearance.BorderSize = 0;
        this.button2.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
        this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
        this.button2.Location = new System.Drawing.Point(343, 1);
        this.button2.Name = "button2";
        this.button2.Size = new System.Drawing.Size(27, 26);
        this.button2.TabIndex = 1;
        this.button2.Text = "[]";
        this.button2.UseVisualStyleBackColor = false;
        this.button2.Click += new System.EventHandler(this.MaxClick);
        // 
        // button3
        // 
        this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
        this.button3.BackColor = System.Drawing.SystemColors.ButtonFace;
        this.button3.BackgroundImage = global::BorderExp.Properties.Resources.blank_1_;
        this.button3.FlatAppearance.BorderSize = 0;
        this.button3.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
        this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
        this.button3.Location = new System.Drawing.Point(310, 1);
        this.button3.Name = "button3";
        this.button3.Size = new System.Drawing.Size(27, 26);
        this.button3.TabIndex = 2;
        this.button3.Text = "___";
        this.button3.UseVisualStyleBackColor = false;
        this.button3.Click += new System.EventHandler(this.MinClick);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.BackgroundImage = global::BorderExp.Properties.Resources.blank_1_;
        this.ClientSize = new System.Drawing.Size(403, 320);
        this.ControlBox = false;
        this.Controls.Add(this.button3);
        this.Controls.Add(this.button2);
        this.Controls.Add(this.button1);
        this.Name = "Form1";
        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        this.Text = "Form1";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Button button2;
    private System.Windows.Forms.Button button3;
    }
   }

the screenshot:-
NoBorderForm

  • Remove From My Forums
  • Вопрос

  • Исходные данные:

    Форма. На форме Кнопка с надписью, например,  Text.

    Событие:

    При клике мышкой на кнопке, вокруг текста кнопки возникает рамка.

    Вопрос:

    Как избавиться от Рамки (или задать её цвет). :)


    SHerkh

    • Изменено

      14 октября 2018 г. 11:47

Ответы

  • Добрый день.

    Создайте свой класс кнопки, потомок от того класса кнопки который вы сейчас используете. Если это стандартная кнопка, то вот так:

    public class MyButton : Button
    {
        public MyButton() : base()
        {
            SetStyle(ControlStyles.Selectable, false);
        }
    }

    Эта кнопка не будет получать фокус, вы, насколько я понимаю, говорите именно про него.

    • Изменено
      Алексей ЛосевEditor
      16 октября 2018 г. 11:09
    • Предложено в качестве ответа
      Maksim MarinovMicrosoft contingent staff, Moderator
      16 октября 2018 г. 12:05
    • Помечено в качестве ответа
      SHerkh
      16 октября 2018 г. 14:07

I have a button on my form that has flat style applied and uses a background image, I have removed all borders from the button, but when I tab onto the button from another control a black border appears around the button.

This can be seen in the image below. On the left is the button with black border on the right is a different button but shows how the cancel button should look.

Buttons

asked Apr 1, 2012 at 17:19

shane12195's user avatar

4

I do not get this border, if I set the BoderSize to 0 in the FlatAppearance section.


Further investigation shows that this border appears only when the button is the default button. You can create your own button, which does never show this border like this

public class NoNotifyButton: System.Windows.Forms.Button
{
    public override void NotifyDefault(bool value)
    {
    }
}

Note: NotifyDefault remains intentionally empty.

answered Apr 1, 2012 at 17:27

Olivier Jacot-Descombes's user avatar

2

You have to make a new button class using IButtonControl and change NotifyDefault to false:

base.NotifyDefault(false);

answered Apr 1, 2012 at 17:24

Saeid Yazdani's user avatar

Saeid YazdaniSaeid Yazdani

13.3k53 gold badges177 silver badges284 bronze badges

You don’t have to create a derived class.
You can set the ForeColor to be the same as parent control BackColor.
As follows :

btn1.ForeColor = btn1.Parent.BackColor;

answered Dec 21, 2015 at 13:03

Amit Lipman's user avatar

Amit LipmanAmit Lipman

6276 silver badges16 bronze badges

You can do it setting the button property «ForeColor» to transparent

answered Jun 10, 2015 at 7:52

nohack12's user avatar

I managed to get around this by setting the button TabStop property to False and then using this code on the button click event

private void sendBackTab()
        {
            System.Windows.Forms.SendKeys.SendWait("+{TAB}");
        }

answered Feb 2, 2016 at 4:30

cbyte's user avatar

cbytecbyte

6717 silver badges12 bronze badges

I have a button on my form that has flat style applied and uses a background image, I have removed all borders from the button, but when I tab onto the button from another control a black border appears around the button.

This can be seen in the image below. On the left is the button with black border on the right is a different button but shows how the cancel button should look.

Buttons

asked Apr 1, 2012 at 17:19

shane12195's user avatar

4

I do not get this border, if I set the BoderSize to 0 in the FlatAppearance section.


Further investigation shows that this border appears only when the button is the default button. You can create your own button, which does never show this border like this

public class NoNotifyButton: System.Windows.Forms.Button
{
    public override void NotifyDefault(bool value)
    {
    }
}

Note: NotifyDefault remains intentionally empty.

answered Apr 1, 2012 at 17:27

Olivier Jacot-Descombes's user avatar

2

You have to make a new button class using IButtonControl and change NotifyDefault to false:

base.NotifyDefault(false);

answered Apr 1, 2012 at 17:24

Saeid Yazdani's user avatar

Saeid YazdaniSaeid Yazdani

13.3k53 gold badges177 silver badges284 bronze badges

You don’t have to create a derived class.
You can set the ForeColor to be the same as parent control BackColor.
As follows :

btn1.ForeColor = btn1.Parent.BackColor;

answered Dec 21, 2015 at 13:03

Amit Lipman's user avatar

Amit LipmanAmit Lipman

6276 silver badges16 bronze badges

You can do it setting the button property «ForeColor» to transparent

answered Jun 10, 2015 at 7:52

nohack12's user avatar

I managed to get around this by setting the button TabStop property to False and then using this code on the button click event

private void sendBackTab()
        {
            System.Windows.Forms.SendKeys.SendWait("+{TAB}");
        }

answered Feb 2, 2016 at 4:30

cbyte's user avatar

cbytecbyte

6717 silver badges12 bronze badges

БЛОГ НА HUSL

  • Деловая переписка на английском языке: фразы и советы
  • Принцип цикады и почему он важен для веб-дизайнеров
  • В популярных антивирусах для ПК обнаружили лазейки в защите

Автор вопроса: O_o

Доброго времени суток господа, у меня есть игра на которой появляются кнопки и пользователь должен успеть их нажать и за это он будет получать очки, кнопки именно появляются и исчезают, на каждой кнопке имеется своё изображение и нужно чтобы вокруг этого изображения не было рамки.Как оно всё выглядит исходно

Во время работы приложения

Источник

Ответы (1 шт):

Автор решения: slippyk

Лучше бы вместо картинки код прилепили для наглядности.

Если нужно убрать рамку у кнопки, то так:

button.FlatAppearance.BorderSize = 0;
button.FlatStyle = FlatStyle.Flat;

→ Ссылка

licensed under cc by-sa 3.0 with attribution.

Понравилась статья? Поделить с друзьями:
  • Как убрать разрешенные угрозы в журнале защиты windows 10
  • Как убрать приложение с панели задач windows 10 на ноутбуке
  • Как убрать разрешения файлов в windows 10
  • Как убрать приложение для открытия файла по умолчанию windows 10
  • Как убрать разрешение на запуск программы windows 10