winforms

WHY! doesn't this dispose of all the objects on the flow panel!?

WHY! doesn't this dispose of all the objects on the flow panel!? the count shows 5 and there are 5 buttonsWithProperties on the form, no other objects are on the form. foreach (ButtonWithProperties itemButton in flowLayoutPanel1.Controls) { itemButton.Dispose(); } It disposes 3 of the object but not the las...

Why do I have to call the Cast<> extension method on a DataGridViewRow?

This doesn't work. var result = from row in grid.Rows where (string) row.Cells["COLUMN_1"].Value == "Test" select row.Cells["COLUMN_2"].Value as int?; But this does. var result = from row in grid.Rows.Cast<DataGridViewRow>() where (string) row.Cells["COLUMN_1"].Value == "Test" select row.Cells["COLUMN_2"].Va...

Change border color of Windows Forms Control on focus

Is there a way to change a border color of some common controls in Windows Forms (TextBox, ComboBox, MaskedTextBox, ...) when they are in focus? I would like to achieve that in my dialog, so when control is in focus it's border becomes blue? ...

Specified items will not be deleted when using ListView.Item.RemoveAt()

I have tried to remove specific items from a listview using the RemoveAt() method. But When I remove it the first time some items will stay. For example: see the image below Code: private void button1_Click(object sender, EventArgs e) { for (int i = 0; i < listView1.Items.Count; i++) { if (listView...

Setting a different taskbar icon to the icon displayed in the titlebar (C#)?

I have both dark and light versions of my application icon; the dark version works best on gray surfaces such as Windows XP taskbar, where the light version works best as an icon in the titlebar. Is there a way I can set the icon in the taskbar to a different icon than the one used in my form in C# (P/Invoke is fine)? ...

this.Close() won't work

I have a windows forms app (c# 4.0) and the "X" button won't close the form, and this.close() won't do it either. Other forms work fine, yet when I copy the designer over to a new form, it breaks that form too! any clues? ...

Key event handlers don't fire at the form level

{Form constructor} this->KeyDown += gcnew KeyEventHandler(this, &Form::Form_KeyDown); ... void Form1::Form_KeyDown(Object^ Sender, KeyEventArgs^ E) { MessageBox::Show("Key = " + E->KeyCode.ToString(), "Test"); } The above event handler never fires. But the form's child controls' handler does. What would be the problem ? ...

Simple Mdi Parent and MdiChild Winforms?

I have three forms 1 is Mdiparent and the other two is simple form (Form1 and Form2). Parent: var frmForm1 = new Form1{ MdiParent = this}; frmForm1.Show(); Form1 : var MParent = new Parent(); var frmForm2 = new Form2{ MdiParent = MParent}; frmForm2.Show(); My Problem is if i Show Form2 from Form1 it goes outside the MdiP...

Implementing an observer pattern with winforms

I have one collection of objects that many of my forms (using WeifenLuo.WinFormsUI.Docking) need to interact with. i.e. If the collection has an addition (or deletion) made in one form, then the other forms respond by refreshing their views. Obviously, an observer pattern would be a good candidate here. However, I am having issues try...

what are the background and foreground colors of a textbox when it's disabled in .net ?

Hi, what are the background and foreground colors of a textbox when it's disabled in .net ? ...

How to force paint after setting Enabled = false in a C# windows usercontrol, not WPF?

Hi, How to force paint after setting Enabled = false in a C# windows usercontrol ? ...

Combining Windows Forms and XNA, but lacks "Game" instance.

Hello, I am currently working on a Map Editor for my 3D game, but I am having some problems getting the using Microsoft.Xna.Framework.Game included. My 3D engine is stored in a library, and the constructor for it needs the Game instance and a GraphicsDevice. The GraphicsDevice is not a problem since i used some example from App Hub (li...

How to scroll in a fixed-size ToolStripDropDown

I am using a ToolStripDropDown control to implement the dropdown portion of a custom ComboBox-like control. In order to be visually appealing, I am imposing a MaximumSize on the dropdown and manually specifying the width of each ToolStripButton within it - the result is a popup which is the same width as the control that activates it, wi...

Which passwordchar shows a black dot in a winforms textbox?

Short question here: In .Net 4.0 Winforms, how do I use the PasswordChar property of a Textbox to show a common black dot as a character? Is there perhaps some font I can use that has this as a character? If I use 'UseSystemPasswordChar = true' it shows an asterisk (*). ...

ComboBox doesn't load users.

Hi guys, here's my code: private void LoadUsersToComboBox() { comboBox1.DataSource = null; comboBox1.DataSource = peopleRepo.FindAllPeople(); /*Returns IQueryable<People>*/ comboBox1.DisplayMember = "Name"; comboBox1.ValueMember = "ID"; } private void button2_Click(object sender, EventArgs e) { ...

How to prevent or override automatic formatting within RichTextBox

How would i prevent text from being automatically formatted when added to a RichTextBox, or better yet, override the formatting that does occur? For instance, the following code sets the text, but then creates a formatted link to a server. rtbSomeField.Text = "\\\\just some text"; Results in I understand why it's doing this, but ...

Closing MDIParent Form, application is still running in task manager

So I can't seem to completely exit the application, I want this to happen when the user clicks the (x) button. is there a certain command like application.exit I can put somewhere (maybe FormClosed()?) Thank you! ...

DropDownButton with a scroll bar

Hey, Does anyone know how to add a scroll bar to a drop down button. I am aware that if the size of the dropdownbutton is fixed you get a small scrolling arrow at the top / bottom however i need a scroll bar within it. thank you ...

How can I get a TabPage from a TabControl based on a Point?

Surely this has got to be easy; I'm just not having any luck with it. How would I get the TabPage of a given TabControl whose tab contains a given Point? For example, if I'm handling the MouseUp event and I want to know which tab the mouse was over when it was released. I tried GetChildAtPoint, but that seems to always return the first...

How much stuff does .net do that isn't required?

As the title states; how much work (as a rough percentage figure, if that's possible) does the .Net BCL do for a typical Windows application that isn't strictly required as far as Windows itself is concerned? Presumably everything that Winforms does that has an analogous functionality in MFC, the latter is the ultra-efficient implementat...