winforms

How to stop Visual Studio from moving and/or resizing controls when opening a project?

I have a certain project that's been problematic in visual studio. The main form has a TabControl with four tab pages, and during initial development, the entire contents of the third tab page would shift down each time the project was opened. (It got really bad if you didn't look at that page for a few days, and the next time you ran th...

Common handler for all right clicks

I would like to create one common handler of all right clicks (or possibly some other unique behavior like middle button click, etc.) happening in my application. They would invoke the same action, e.g. fire up dialog to customize control that was clicked or display help dialog for it. Is there a mechanism, which would allow me to inter...

What is the best user interface for showing hierarchy within a hierarchy in a WinForm app

We have the following hierarchy: Environment->Machines->Local contents within a machine We are planning to show this hierarchy using an in-place navigation just like the Windows File explorer feature in Vista and beyond. We have a set of performance counters for environments and for machines. In addition, these counters also have an ...

C#.Net Windows application - Getting Logged user name in My NT

I need to get the username who logged in particular machine in my LAN. Suggest me a best method to get the user name by passing machine name in C#.net windows application. Also consider the permission. Thanks ...

Programmatically select a datagridview row doesn't fire bindingsource.currentchanged event

This is a Winform C# question. I have a customized datagridview which is bound to a bindingsource. There is a listener listening to bindingsource.currentchanged event. When I subscribed the customized datagridview's sorted event and programmatically select a row, the bindingsource.currentchanged event is not fired: dataGridViewExtende...

How can I remove the input focus from textbox?

Hi, I'm making simple C# Winform application. There is a Form having a textbox. I want to change the location of textbox by arrow key but textbox has the input focus so form's KeyDown event is not called. How can I remove that input focus? Typing on the textbox should still be possible. I try to make a dummy label and give the focus, bu...

"Not Connected" message in Visual Studio 2010 when using TFS

In Visual Studio 2010 Premium I have a project that is connected to TFS. Sometimes I see "not connected" messages on the tabs of individual files when open in VS2010. All TFS related functionality (i.e. "Check Out For Edit") seems to be working correctly. Here's a screen snippet from a VS2010 Winforms project to show what I'm talking a...

Splash screen doesn't hide - using Microsoft.VisualBasic library

Hi, I have 2 forms. Form1 (with code below) and Splash (just default form for test). My problem is that after application run the Splash doesn't hide. Main form is loaded but Splash is still not closed. The Form1 code: using System; using System.Collections.Generic; using System.Windows.Forms; using Microsoft.VisualBasic.ApplicationS...

How to auto size a form around a tab control + more controls

Dear reader, I have a form that has several controls: ProgressBar at the top of the form (docked) A TabControl at the top of the form (also docked but underneath the progress bar) Buttons, TextBoxes and labels inside TabPages of the TabControl FlowLayoutPanel at the bottom of the screen (docked) with a few buttons in it Label at the...

Is it possible to read-lock a file?

I'm developing an application which checks for changes made to a file by a separate program (not written by me). If a change is detected, it opens the file, reads the last line, then closes the file. I'm using the following code to make sure my program doesn't try to lock the file, but only opens it in read mode: FileStream fs = n...

LINQ SubmitChanges() Behaviour

Hello, I have a Windows Form application using LINQ to SQL. It's working all good and fine but there is one thing I fail to understand. In one of the forms, I have a DataGrid which shows a list of order items. When I save them using SubmitChanges(), in the first call (after the application has been run) it saves the ALL the order item...

Disallow ListView to have zero selected items

My project is .NET/WinForms. I have a list view which is always filled with items. I would like it to have selection always. However, if I click on an empty area below list view items, it looses selection. The list has multiple selection = true and hide selection = false. ...

help with C# code for fast search

hi i have this code that can do fast search on database. it works excellent on sqlCE. now i need to translate that it will work on Access 2007 how to do it ? public bool LOOK() { Tmp = ""; MAK = ""; DES = ""; Cmd.CommandType = CommandType.TableDirect; Cmd.CommandTex...

A problem with overriding OnPaint when DoubleBuffered set to true

I have created a custom control which derives from Panel. I use it to display an Image using BackgroundImage property. I override the OnClick method and set isSelected to true then call Invalidate method and draw a rectangle in overrided OnPaint. Everything goes just fine until I set DoubleBuffered to true. The rectangle is drawn and the...

C# Winforms Dictionary DataGrid Binding Auto-Refresh Without Losing Focus

Setup C# WinForms Application. Summary Binding a dictionary to a datagridview. Updating the dictionary automatically updates the datagrid. The datagrid does not lose focus when the update happens. The binding works both ways (editing values in the grid updates the dictionary. Scenario I have a class that calculates values based...

Has anyone got an Infragistics WinForm Combo working with a dynamically populated data source?

I've got a simple requirement: when the user types something in a combo, my app will go out somewhere and get a list of relevant items that might match what they want. e.g. if they type 'A', it'll go out and get all books beginning with A. I initially used the standard .NET combo with a custom auto-complete data source, but that kept cr...

Add static library to CLR Windows Forms Project, Get "unresolved external symbol _MAIN__"

I've reduced this issue to, with Visual Studio 2005, in Release mode: Create a new Windows Forms app Change to /CLR Check that the default Form1 runs Add one static library (which itself is linked with BLAS.lib, clapack.lib, libf2c.lib) Then I compile and link and get error LNK2019: unresolved external symbol MAIN_ referenced in...

Sort search results from text file into listbox

Hi scene! what i have is a textbox into which the user types a string. The string will look something like this: G32:04:20:40 Then the user hits the search button. The program must then open a textfile and search for the "nearest" five strings to the one they entered and display them in a listbox. I'll define "nearest string" as much ...

How can I fire an event so my other form reacts to it?

I have this form called MainForm.cs. When I click Enter The Progam button I display another form using the .ShowDialog() method. In this new form called LoginBox.cs, I check if the entered credentials are valid and if they are I want my MainForm.cs to react with either a positive responde (the actual software form opens) or negative res...

C# How to get the date mouseover with a DateTimePicker?

I want to add a tooltip to the DateTimePicker Calendar that show some informations based on the date that the mouse is over. Is there a way to retrive the date under the mouse without clicking it? ...