winforms

Help creating a Windows Form for an Entity who has a reference to a different Entity.

Here is the scenario (ADO.NET Entity Framework and C#). Contact*: String name; Address addr; Address*: String street; String city; *this is not the real code, but you get the picture I am trying to create a Windows Form that appears flat to the user. In other words, the Form will have four fields (name,addr,street,city), and whe...

Text alignment in a dropdown list

I have a Winforms dropdown. The drop down displays a string that is in the form of... <Description 30chars> Weight:<weight 6chars> Thickness:<thickness 6chars> I need the strings to line up so Weight always starts at the same spot. So when there is a list of them everything lines up nicely. My current solution was to use a monospaced...

In .NET, How can I draw shapes on a picture ?

I'm doing a software where I need to put squary bordering fields on a satelite map (.png image), so that the fields can be clicked. What is the best way to add shapes on a picture and associate them with data ? ...

Binding a ListBox's SelectedItem in the presence of BindingNavigator

Hello. I'm trying to bind a ListBox's SelectedItem data to a property. The following code is an example: using System; using System.Collections.Generic; using System.Windows.Forms; namespace BindingFailure { static class Program { class OuterObject { public string selected { get; set; } public List<string> strings { get; se...

Disable the 'requirement' to double click an unfocused window when clicking on a menustrip

Sorry about the weird title, I'm currently playing around with WinForms and I'm wondering if there is any way to make it so that you don't have to 'double-click' the window to activate an item in a menustrip when the window is unfocused? Currently if the window is unfocused I first have to click on the window to give it focus and then ...

How to build a Windows Forms email-aware text box?

Hi, I'm building a C# client app that allows a user to communicate with one or more existing users in a system via an email-like metaphor. I'd like to present the user with a text entry box that auto-completes on known email addresses, and allows multiple delimiter-separated addresses to be entered. Ideally, I'd also like the email addr...

How do you get the solution directory in C# (VS 2008) in code?

Hi, Got an annoying problem here. I've got an NHibernate/Forms application I'm working through SVN. I made some of my own controls, but when I drag and drop those (or view some form editors where I have already dragged and dropped) onto some of my other controls, Visual studio decides it needs to execute some of the code I wrote, includ...

Databinding with Control Properties in Winforms: Bind Enabled to state of Combobox?

Hi all, I have barely any experience with WinForms, but I'm fairly sure that this is a simple task. I just need to enable and disable the Enabled property of a textbox based on the SelectedIndex of a ComboBox. Can this be done in the designer using DataBindings, or am I required to write a handler of some kind? ...

dynamically created datagridview columns not accessible unless added to a form...why?

We simply created a DataGridView control dynamically and bound it to a DataTable. We were tying to style certain columns. But, when we tried to access the columns we got a null reference. On further investigation we found that if we add the DataGridView control to the main form, and then try to access its columns, it works fine!!! Code...

Why doesn't my dataset.AcceptChanges update some new rows i've added?

I have a dataset in a datagrid with some data in it. Recently I've been asked to add some data to that dataset along with some controls to save the data from. I've added a few textboxes, 1 combobox and 3 textboxes that function as viewing of some datetimepickers that I have to use for dates. I've chosen to use textboxes in combination ...

C# database file directory

I'm using the windows forms aplication with an ms access database. And i would like to know if there is a way to show the directory of the database file (to save data in it)excpet like this: string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=save.mdb"; OleDbConnection empConnection = new OleDbConnection(con...

c# vet user data

In a couple of fields in my Windows Form application, I am asking a user to supply either an IP address or a hostname. Is there a good RegEx to take care of this business? I would prefer that the user enter a FQDN or IP. Is there a nice way to test for this? ...

Is there a way to avoid throwing/catching exceptions when validating Textboxes used for number entry?

Hey all, In the pursuit of elegant coding, I'd like to avoid having to catch an exception that I know well may be thrown when I try to validate that the Text field of a Textbox is an integer. I'm looking for something similar to the TryGetValue for Dictionary, but the Convert class doesn't seem to have anything to offer except exception...

Making legacy straightforward win.forms application code more clear

I have legacy win.forms application written in pretty straightforward approach where forms communicate with DAL on UI events. For example there are textboxes: login/password, button - "Login" and a click-handler where business logic is implemented (DAL is asked to get user by id/password, if not null - than show next screen, if null - sh...

Show ContextMenuStrip from ToolStripDropDown without dismissing ToolStripDropDown

I have a ToolStrip. In my ToolStrip I have a ToolStripDropDownButton. My ToolStripDropDownButton has a DropDown of type ToolStripDropDown that contains a ToolStripControlHost which contains a Label. I have assigned a ContextMenuStrip to my Label. When I show the DropDown and right-click on the label, the ContextMenuStrip displays cor...

passing values between forms (winforms)

Hello. Vierd behaviar when passing values to and from 2nd form. ParameterForm pf = new ParameterForm(testString); works ParameterForm pf = new ParameterForm(); pf.testString="test"; doesn't (testString defined as public string) maybe i'm missing something? anyway i'd like to make 2nd variant work properly, as for now - it returns...

Capture Combination Key Event in Win Form

When the user presses SHIFT+UP key, I want my form to respond by calling up a message box. How to do this in Windows Form? ...

List View doesn't render items in Details view

VariableBox = gcnew ListView(); VariableBox->Font = ScriptEditorOptions->FontSelection->Font; VariableBox->Dock = DockStyle::Fill; VariableBox->BorderStyle = BorderStyle::Fixed3D; VariableBox->BackColor = ScriptEditorOptions->BCDialog->Color; VariableBox->ForeColor = ScriptEditorOptions->FCDialog->Color; VariableBox->DoubleClick += gcnew...

How to easily salt a password in a C# windows form application?

How can I easily salt a password from a Textbox.Text? Are there some built in wizardry in the .NET framework? ...

ComboBox: Adding Text and Value to an Item (no Binding Source)

In C# WinApp, How Can I add both Text and Value to the items of my comboBox? I did a search and usually the answers are using "Binding to a source".. but in my case I do not have that source ready in my program... how can I do something like this: combo1.Item[1] = "DisplayText"; combo1.Item[1].Value = "useful Value" ...