Windows forms hide window

Скрыть форму при запуске

Нужно скрыть вторую форму при запуске
Люди помогите. Нужно при нажатии кнопки в form1 открыть form2 и скрыть ее сразу. Открытие.

При первом запуске программы показывать первую форму, а при остальных вторую форму
при первом запуске программы показывать первую форму а при остальных вторую форму

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

Как скрыть form1 при запуске программы?
Как скрыть form1 при запуске программы?

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

Скрыть при запуске главную Form1 и открыть Form2
Приветствую. Суть описана в заголовке) Требуется, чтобы после запуска exe открывалась сразу 2я.

Как скрыть форму при клике вне её
Привет, ребят 🙂 Тема такая, есть приложение, которое вызывается из трея нажатием на иконку, но и.

Скрыть родительскую форму при открытии дочерних форм
Даценд, а вопросы таковы: 1) Хочу скрыть родительскую форму при открытии дочерних форм, но проблема.

При запуске программы создать обе формы, а потом первую скрыть, вторую показать
У меня проект с двумя формами. Одна главная, а другая появляется при нажатии кнопки. Вторая.

Скрыть главную форму, чтобы показать вторую

Здравствуйте что неправильно делаю?

При загрузке первой формы (form1 load) хочу показать вторую (form2). При загрузке второй формы(form2 load) хочу скрыть первую

Скрыть и отобразить главную форму
Подскажите пожалуйста. В моем проекте 2 формы Form1 и Form2, Form1 является главной формой. Как.

Как скрыть главную форму
Здравствуйте, как скрыть главную форму, в моем случае это Form1 и показать Form2 и чтобы при.

Как показать вторую форму из первой
Подскажите пожалуйста, что нужно чтобы банально вызвать форму из другой формы? Из кода в этой теме.

Показать главную форму из дочерней не создавая новый объект
Доброго времени суток. Столкнулся с проблемой. Допустим, при запуске приложения открывается.

а зачем ты во второй процедуре опять создаешь новую форму форм1?

Добавлено через 47 секунд

В C# нету процедур. Есть методы.

Так чисто даже теоретически не должно работать.

Правильно так, но первое окно не скрывается:

в данном случае ошибка:
Ошибка 1 Для нестатического поля, метода или свойства «System.Windows.Forms.Control.Hide()» требуется ссылка на объект

теперь при закрытии первой формы открывается вторая. что в принципе меня устраивает — уже не устраивает((

Добавлено через 54 минуты

В общем в первой форме указываются параметр -это сервер к которому нужно подключиться.
Вторая форма это соответственно интерфейс клиента.

попорядку:
загружается первая форма, в ней указывается сервер(ну если уже есть сервер то не надо указывать). По истечению допусти 5 секунд если пользователь не нажимает кнопку «настроить», то запускается вторая форма а первая исчезает

Читайте также:  Окна windows имеют много цветов

На второй форме вообще ничего писать не нужно

если возвращаться не нужно, правильное решение в 6 посте

Добавлено через 12 минут
blacksmithov, почитай внимательно о классе Form. Событие Load вызывается перед отображением формы, а ты уже в нем вызываешь Form2, хотя тебе нужно отображать Form1 еще 5 сек.
Логика поведения приложения совсем непонятна, сядь и распиши на листике (лучше с диаграммой), что за чем и когда должно открываться.

Не, ну если другой способ подошёл, то и этот работает! Просто вызов Hide() не скрывает главное окно. Вот о чём я говорил. А так уж извини, о целях изврата с окнами в курсе небыл.

Чтобы окно скрывалось, надо чтобы свойство ShowInTaskbar у главного окна было false.

Тематические курсы и обучение профессиям онлайн
Профессия‌ С#-разработчик‌ (Skillbox)
Архитектор ПО (Skillbox)
Профессия Тестировщик (Skillbox)

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

При запуске программы создать обе формы, а потом первую скрыть, вторую показать
У меня проект с двумя формами. Одна главная, а другая появляется при нажатии кнопки. Вторая.

Показать скрыть форму
Добрый вечер, есть парочка вопросов: 1. Как при нажатие кнопки показать форму2 и скрыть форму1 .

Скрыть/показать форму
Помогите как сделать,что б при нажатии на кнопку открывалась соответствующая форма и пряталась.

Открыть вторую форму и скрыть первую
Скажите почему в форме, которая содержит класс, нельзя сделать вот так: Form2 a=new Form2();.

Winforms — how to show/hide elements in designer?

I am trying to make a multiple page application using winforms. I decied to use multiple Panels — each panel represents different page, so I can switch between them when I need to display different content.

My problem is about stacking panels in designer view. When I have 2+ full screen panels, they all stack on each other and I can’t see the one that I created earlier. Is there any solution to this ? Changing visibility does not affect designers view. Think of it as a photoshop-like option to show/hide layers. I’m using Visual C# 2010 Express.

7 Answers 7

Several options here:

  1. Use the Document Outline view ( View —> Other Windows —> Document Outline ) to select the panel you care about. You can right-click on it and choose Bring to Front to put it in front of everything else.
  2. Though it’s probably not relevant to what you’re doing, you might consider using a TabControl , which you can mess with visually at design time. This is only a reasonable solution if you want your users to be able to manually change which panel they’re viewing.
  3. Consider moving your panels into custom UserControl classes and work on them separately. If the content and logic of these panels is reasonably self-contained then you may want to do this anyway just to better restructure your code.
Читайте также:  Cross compiling from linux to windows

Addendum: You can also use a hack that makes a TabControl ‘s tabs invisible to the user. Put a TabControl on your form, and at run-time set the ItemSize height to 1. This makes it (almost) impossible for the user to change the tabs on their own, but still allows you to change the visible tab in the designer.

Note that I called this a hack for a reason: TabControl s were not meant to be used this way. It’s something that appears to work, but like all hacks it may break at any time so you should only do it as a last resort (and don’t blame me if it causes headaches later on. ). In short, I do not recommend this hack, I only offer it as a possibility.

How I hide close button in c# windows form [duplicate]

I have a modal dialog, and need to hide the Close (X) button, but I cannot use ControlBox = false, because I need to keep the Minimize and Maximize buttons.

I need to hide just Close button, is there any way to do that?

3 Answers 3

Although you can disable the close button as the answers here (and to the duplicate question) have suggested by adding the CS_NOCLOSE style to the form’s window class, consider very seriously whether you really need to do that.

You still have to give the user some way of dismissing the modal dialog, presumably with buttons on the dialog itself. And since one of those buttons is probably «Cancel» or the equivalent, you should just make the Close (X) button do the same thing as «Cancel». (Handle the FormClosing or FormClosed event for your form if you want to customize the default behavior or do something special on closure.)

Note that the Windows UI guidelines for dialog boxes state explicitly that you should not disable the Close button because users expect to see it and it gives them a feeling of security that they can always safely «get out» of whatever popped up on the screen if they don’t want it:

  • Dialog boxes always have a Close button. Modeless dialogs can also have a Minimize button. Resizable dialogs can have a Maximize button.
  • Don’t disable the Close button. Having a Close button helps users stay in control by allowing them to close windows they don’t want.
    • Exception: For progress dialogs, you may disable the Close button if the task must run to completion to achieve a valid state or prevent data loss.
  • The Close button on the title bar should have the same effect as the Cancel or Close button within the dialog box. Never give it the same effect as OK.
  • If the title bar caption and icon are already displayed in a prominent way near the top of the window, you can hide the title bar caption and icon to avoid redundancy. However, you still have to set a suitable title internally for use by Windows.

Even with progress dialogs, which Microsoft calls out as an «exception» to this general rule, it’s often very desirable to make the operation cancellable.

Читайте также:  Arch linux gtx 1650

Hiding forms on startup: why doesn’t this.Hide() hide my form?

I wanted to hide the main window of my app on startup, so I put this in the constructor:

This doesn’t hide my form though. It seems like I can only get buttons to hide the form. Am I doing something wrong here?

7 Answers 7

you can use this line of code. It wont hide it, but it will be minimized:

in addition, if you don’t want it showing on the task bar either, you can add this line:

But why do you create the form if you don’t want it to be visible in the first place?

Just override the OnVisibleChanged method and change the visibility of the form in there, something like this:

And that’s it! Simple and clean.

If you would rather use this.Hide or this.Show you can do this

I tried to do this by setting Visible to false or hiding in the constructor and in the OnLoad event.

Neither of these had any effect, as the form is set to Visible after the form is created and after the OnLoad event is fired, in SetVisibleCore.

Setting the form to hidden in the Shown event works, but the form flickers on the screen for a moment.

You can also override the SetVisibleCore and set the value to false, but then OnLoad isn’t fired and some of the other events are messed up, such as form closing.

The best solution in my opinion is to set the form to minimised and not shown in the taskbar before calling Application.Run().

Then the application will run with all the proper events fired (even OnShown) and the form will not be displayed.

If you want to be able to hide / show the form like normal after that, then you need to set the WindowState and ShowInTaskbar back to Normal and true.

In the Shown event, you can set ShownInTaskbar back to true and then properly hide the form.

Settings the WindowState back to Normal whilst the form is hidden has no effect, so you will need to do it after you show the form again, otherwise the icon will be in the taskbar but the form will be minimised.

Оцените статью