winforms

How do I set an image for some but not all nodes in a TreeView?

I have a TreeView windows forms control with an ImageList, and I want some of the nodes to display images, but I want the others to not have images. I don't want a blank space where the image should be. I don't want an image that looks like the lines that the TreeView would draw if it didn't have an ImageList. How do I get it to draw ...

AccessViolationException from a combo: Attempted to read or write protected memory

Users are occassionally getting the above error when using our application (VB.Net, Winforms, using v2 of the framework). I'm not able to reproduce it. The callstack is as follows: : System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at System.Window...

VB NET Listing drives and VMWARE

This is a strange one... In a windows forms app (VB.NET/VS 2005) I have the need to occasionally check if the application DVD is inserted. In my production machine (and in the majority of our clients) this code takes less than an second to execute. But in some machines, it takes about 8 to 10 seconds. I couldn't find any common ground on...

How to scroll a panel manually?

I want to use the same functionality available when a Panel.AutoScroll is true, but with the scrollbars invisible. To do so I need to know how can I scroll to left/right up/down using functions in my code. ...

.Net 2.0 Winform Label Tool Tip

This has got to be something I just missed, but how do I add a tool tip to a label? I saw something on the web about handling the mouse hover event, but how would I even handle it in code? ...

.NET Minimize to Tray AND Minimize required resources

I have a WinForms application (I'm using VB) that can be minimized to the system tray. I used the "hackish" methods described in multiple posts utilizing a NotifyIcon and playing with the Form_Resize event. This all works fine aesthetically, but the resources and memory used are unaffected. I want to be able to minimize resources when ...

Report Viewer - Request for the permission of type SqlClientPermission failed.

I am using the ReportViewer control from Visual Studio 2008 in Local Mode with objects as the data source. My classes are mapped to data tables in my database. In the objects, it loads related objects as needed. So it leaves the reference null until you try to use the property, then it tries to load it from the database automatically. Th...

Adding an Excel file to be published with Window Apllication

Hi Guys, I have been trying for an hour or so and cannot get this right. I have a Visual Studio project which reads an Excel file, which I have added to the VS solution. When I run the project in VS, the file can be opened successfully. However, when I publish the project, the file does not get included, and therefore cannot be opened by...

How to set the "insert new row" as first row in DataGridView

Hi there I am trying to get the DataGridView to render the "insert new row" row as the first row in the grid instead of the last row. How do I go about doing that, is it even possible in the control? Regards, Egil. ...

How to call the main program from a winform opened by it'?

I have a program that when it starts, opens a winform (it is the one specified in Application.Run(new ...). From this form I open another form: OtherForm newForm=new OtherForm(); newForm.Show(); How can i communicate from the new winform with the form that opened it? So that I can add some items in it. ...

Multiple control buttons for a maximised MDI child in .NET WinForms

That's what I get when I try to automatically maximize MDI children. The code is something like this: this.IsMdiContainer = true; child = new Form(); child.MdiParent = this; child.WindowState = FormWindowState.Maximized; child.Show(); Any ideas why do I get multiple control buttons ? ...

How to structure VB.NET windows forms applications

What is the best way to structure a VB.NET windows forms application so that code can be reused and the app can be extended easily. I used to create lots of new forms. This lead to lots of repeated code and forms which did similar things. Now, for forms which do similar jobs, such as view/edit/delete items from a specific db table, I c...

Counting the number of unique image occurences in a DataGridViewImageColumn

In a DataGridView bound to a DataView, where cells in a column will contain one of two images from an ImageList (e.g. a green 'online' image or a red 'offline' image), how can you sum the number of occurences of each image when iterating through the DataGridView's rows? The Value and FormattedValue properties of DataGridViewImageCell re...

What is the best mechanism for storing authentication settings in a WinForms app

I have an App that will send authenticated emails using System.Net.Mail and System.Net.NetworkCredential my question is how should I store the password that is needed to create a NetworkCrednetial object? The application doesn't have a login but I could setup an option that allows the user to enter their email credentials (in almost all...

Stop System.Windows.SplashScreen with WinForms from closing the app

I'm using System.Windows.SplashScreen to add a splash screen to my WinForms app (it has a lot of WPF controls, but the 'main window' is still a System.Windows.Forms.Form object). When the splash screen closes the whole app goes as well. Can I stop it taking the whole app with it? ...

Winforms ComboBox SelectedValueChange event

How do I prevent code from executing in the SelectedValueChange event of a combobox when the combobox is being loaded for the first time? I need the code to execute when the user has selected a new value. ...

How do I use XML as a datasource for a datagridview in a winforms project?

How do I link an editable datagridview to an XML file in a winforms project? ...

Show new WinForms window unfocused

I'm generating and showing a new WinForms window on top of a Main Window. How can I achieve that the original (Main Window) keeps the focus? Setting the focus back after showing the new window does not solve my problem because I need to prevent the Main Window's title bar from flickering. The new window has to stay on top of the Main Win...

Passing AD authentication credentials via IE browser in C# Windows Form

We have a Windows Form application which hosts an IE browser control. Our users run the application and open links to documents stored in MOSS. We are trying to set the application up to pass in credentials of a service account so that we can avoid giving all users access to the MOSS site. We have used code found here which seems to work...

Disable DataGridView System ContextMenu

Does anyone know how I can disable the System Context Menu when a user right clicks in a DataGridViewTextBoxCell? I have tried to override the WndProc at the DataGridView level (as there is no WndProc to override on the Cell level), but nothing seems to work. Any help would be greatly appreciated. The following is what I use to achie...