winforms

How are you supose to access a DataGridView in a form?

Usually when I add a control to a form using the Visual Studio GUI it writes all the code that defines the control is in a separate partial class file named ".Designer.CS". This partial class usually contains private fields for each control so the non-designer partial class can access the controls. I've added a DataGridView in a GroupBo...

Is it possible to align a serie of label / textbox vertically with flowlayoutpanel ?

I would like to align like this label1 TextBox1 label2 TextBox2 label3 TextBox3 I set FlowDirection to TopDown but how can I do to align label1 with TextBox1 horizontally ? ...

[C#] Program Not Responding

Ok hi, I am making a program in Microsoft Visual Studio and every time I run it and and click start (I have a start button), it will do what I have it programmed to do, but the form always freezes and doesn't display what i want it too (it says "Not Responding" once i start it). It is good for doing it job, but I have things on the form ...

Reading line by line

I have a program that generates a plain text file. The structure (layout) is always the same. Example: Text File: LinkLabel "Hello, this text will appear in a LinkLabel once it has been added to the form. This text may not always cover more than one line. But will always be surrounded by quotation marks." 240, 780 So, to explain wha...

Inherited form problem

i have a windows form that inherites from another windows form in the same project, the problem is when i click a button in the inherited form the eventhandler fires twice performing the event in the parent form and then performs the event in the inherited form . any suggestions? http://www.metacafe.com/watch/852308/inheritied%5Fforms%5...

Label Text Pair Control in .NET

In .NET we have a label control and a text control, but what about a single control that includes them? I am working on a Windows Form application. Sorry for not making this clear. Edit: I know I can make it myself (everyone, anyone can), but I am looking for a built-in one. ...

Adding Control based on info in txt file

Following code, credit: Guffa. Hello All, I'm trying to add controls to a Form at runtime based on the information found in a Plain Text File. The structure? of the text file is always the same, and will not change. Example: File.txt: Label "This is a label" 320, 240 Explanation: Control Text Location The following code, pr...

C# - Binding TextBox to an integer

How to bind a TextBox to an integer? For example, binding unit to textBox1. public partial class Form1 : Form { int unit; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { textBox1.DataBindings.Add("Text", unit, "???"); } ...

C#/WinForms: Do I need the IWin32Windows?

When writing WinForms application with proper separation between View- and Controller/Presenter-functionality, I often find myself writing code like this: public void class SomeView:Form{ private void loadFileButton_Click(object sender, EventArgs e) { _loadFileAction.Execute(this); } } public void class LoadFileAction:Action{...

Getting initial dimensions from inherited UserControl

I am trying to create a series of UserControls that all inherit from a custom UserControl object. One of the key behaviors I want to implement is the ability to dynamically resize all of the controls to fit the control size. In order to do this, I need to get the initial width and height of the control to compare it to the resized dime...

Send a message to a Windows Forms message loop

I have a thread that reads messages from a named pipe. It is a blocking read, which is why it's in its own thread. When this thread reads a message, I want it to notify the Windows Forms message loop running in the main thread that a message is ready. How can I do that? In win32 I would do a PostMessage, but that function does not seem t...

Quirky Winforms Font Behavior On MouseHover

So I'm working on a basic subclass of Label that supports editing. The editing part works fine--I insert a text box with no background color or border on click, commit changes on enter or loss of focus. The little thing that's giving me trouble is related to some basic font styling. The label is to underline with the MouseHover event (...

Auto validation in Winforms in a dedicated label: Redux using DataSets

I had asked this question: http://stackoverflow.com/questions/1491129/auto-validation-in-winforms-in-a-dedicated-label The answer was right, and I got thinking more: How to do this, using DataSets? I stumbled upon this link: http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/2367f061-4124-4050-8318-55193193c2d...

event handlers for items of contextmenustrip

Hi, I am adding a right click functionality on individual nodes of a treeView in my C# code. The options like "Add", "Delete", "Rename" should pop up when the user right clicks in those nodes on the tree. Now depending on the node that is being clicked, I am filling up the menu as using the following statememnts: contextMenuStrip1.Item...

.NET Windows Forms Refresh Control

I have a simple program which loops through a resultset when a button is pressed and performs actions against this resultset (stored in a DataTable). During the loop I update the text of a RichTextBox, 2 labels, and a ToolStripStatusLabel. These are not refreshing during the loop so after each item is processed in the loop I do a this.Re...

Foreach Control in form, how can I do something to all the TextBoxes in my Form?

How can I use a Foreach Statement to do something to my TextBoxes? foreach (Control X in this.Controls) { Check if the controls is a TextBox, if it is delete it's .Text letters. } ...

.Net form focus

I Have a .net form with multiple controls in it.. Textbox , labels ... When the form is shown on screen the textbox get the focus by default. When i try to scroll the form using mouse scroll wheel the scroll messages are basically going to Textbox and hence the form is not getting scrolled.. I tried setting textbox.capture = false fo...

winform basic navagation

Hi, Ho do I open a winform within another winform and disable the parent? I want to create a log in. So I create a form and this form open the log in form, but I want to disable the one that opens the log in form. thanks ...

How do I prevent my custom tooltip code from drawing when that part of my window is obscured by an always-on-top window?

We have implemented some custom tooltip-drawing code that fires on Tick events of a timer. Whenever this event fires, we check to make sure our control is visible (this.Visible) and is the foreground window (GetForegroundWindow()). The problem we are having involves "always on top" windows like Task Manager or Process Explorer (when the...

Unhashing a hash C#

Can someone reverse this handy hash code I'm using? using System.Security.Cryptography; public static string EncodePasswordToBase64(string password) { byte[] bytes = Encoding.Unicode.GetBytes(password); byte[] inArray = HashAlgorithm.Create("SHA1").ComputeHash(bytes); return Convert.ToBase64String(inArray); } Everything I en...