winforms

2 or more Controls only 1 is considered Active

I have 2 controls (MyCtrl) next to each other called ctrlLeft and ctrlRight. Whenever one receives interaction it is considered active (by default the left one). I override OnDraw and customize the look of the active one a bit. Currently I have a property Active and an event that I subscribe to from all MyCtrl in there I store a refere...

Is there a better way to avoid an infinite loop using winforms?

I am using .Net 3.5 for now. Right now I am using a using trick to disable and enable events around certain sections of code. The user can change either days, hours, minutes or total minutes, and that should not cause an infinite cascade of events (e.g. minutes changing total, total changing minutes, etc.) While the code does what I wan...

Is it possible to disable textbox from selecting part of text through double-click.

The default behaviour of doubleclicking in a textbox is select part of text. I wanna override it with selecting a word. But I found handling the doubleclick event(or override the OnDoubleClick method) actually do the default behaviour first, then execute my code. Is it possible to disable the default behaviour. ...

How to give a textbox a fixed width of 17,5 cm?

I have an application with a textbox, and the width of the textbox on the screen must always be 17,5 centimeters on the screen of the user. This is what I tried so far: const double centimeter = 17.5; // the width I need const double inches = centimeter * 0.393700787; // convert centimeter to inches float dpi = GetDpiX(); // get the d...

Maximized MDI form behavior

My program shows some browser. From a browser user can open maximized MDI form with some report. When user is closing the report, first MDI form with browser is became maximized. 2 forms have same MDI parent. Can I change this behavior to leave my first browser form without maximizing after second report closed? ...

DevExpress NavBar: Appearance has no effect

Hi all, this question is fairly DevExpress-specific. I use a NavBar control with the standard "SkinExplorerBarView" in a WinForms app, and would like to change the appearance of a selected navigation link. I changed the background color of the control's "ItemPressed" and "ItemActive" appearances, as well as each single item's "Pressed...

How to make a panel center of form ?

How to make a panel center of form, even if the size of the form is changed. Using c# windows application ...

C# Why is a treeview node clicked when canceled is set to true?

In my winform application I have a treeview. To give the idea that a node is disabled I set the node's forecolor and I when the BeforeSelect fires I set e.cancel to true. However when a node's tag meets some criteria a node may be selected. So that's why I have a NodeMouseClick. But when a node may not be clicked I set the e.cancel to t...

How should I name form controls variables and their event handlers in WinForms?

Hello, I have a little coding style problem - what names should I choose for controls in Windows Forms in my application? I think that best approach is to not generate the field at all (GenerateMember property), this can work at buttons, separators, menu items etc. But there are for example some labels and controls that I need to refere...

C# Ordered dictionary index

I am considering of using the OrderedDictionary. As a key I want to use a long value (id) and the value will be a custom object. I use the OrderedDictionary because I want to get an object by it's Id and I want to get an object by it's 'collection' index. I want to use the OrderedDictionary like this: public void AddObject(MyObject ob...

Image.Location variant for WPF?

Hi All I'm a noob when it comes to WPF; In win forms I can do this: public void blah() { using( var o = new OpenFileDialog()) { if(o.ShowDialog() == DialogResult.OK) { PictureBox p = new PictureBox(); p.ImageLocation = o.FileName; p.AutoSize = SizeMode.AutoSize; ...

help me to cheat with numericUpDown1_ValueChanged event

I have a Form and numericupdown control located on it. I want that in some conditions (_condition1) user cannot be able to change a value of numericupdown control. How can I do it ? I wrote some code but it works twice (double time). class Form1 : Form { bool _condition1; int _previousValue; void numericUpDown1_ValueChange...

in CellMouseDown want to get the style set in CellFormatting

Hi, in CellFormatting event handler of the my DataGridView object, i'm changing the CellStyle attribute as e.CellStyle.BackColor = Color.LightGray; this shows up fine in the UI. When I tried to get the BackColor of the cell in CellMouseDown event, the object doesn't show up the Color.LightGray color... I tried all possible combinati...

WinForms: Why is Control.Parent null?

I'm trying to get the parent of a listview docked within a splitcontainer, and am finding that ListView.Parent is null. According to the documentation this should be: A Control that represents the parent or container control of the control. Can anyone explain why this property would be null? I've tried moving the ListView to the ...

How can I reorder columns in a DataGridView?

so I fill my DGV with some data and set some columns invisible: var part = inventory.espiromex_product.Where(p => p.descriptionsmall == cmbMainP.Text).First().partnumberp; dtgAssy.DataSource = inventory.espiromex_productsub.Where(p => p.partnumberp == part); dtgAssy.Columns["idproductsub"].Visible = false; ...

How to access parents' members from a inner class in WPF?

Hello Experts! I'm trying to do scheduled operation let's say to check for user's credit left via web service call and update the user interface. i've tried with quartz.net to implement the scheduling bit.i created an inner class in the window class i need to update.That inner class has the method that calls the webservice and the resu...

C# - Printing the Form

I am using the code from MS to print a form however it looks like the form needs to be visible with a Show/ShowDialog() to work. I am trying to use the code for a form that I don't want to show. Any ideas? ...

How create custom user interface for Windows?

There are many applications for Windows these days that don't use native windows controls, don't have standard window frames and generally look different. What are some recommended techniques for creating such interfaces? ...

Recommended WinForms control for lots of read-only formatted text.

I`m working in a serial terminal project developed in VB.NET. I need to display a lot of formatted (color, font styles) text data in a read-only control (the incoming serial data). I don`t know if it's a good idea to use richtext control or a grid, or there's a better third party control? Thanks ...

Closing Windows Forms on a Touchscreen

Our clients have fat fingers, and so do we. We take touchscreen netbooks apart to insert them into our custom hardware, and I write a software interface that shows up on the touchscreen. The problem is that it has about a 3/4" bezel over the screen, which means hitting that little red "X" becomes a challenge, especially considering reduc...