winforms

how to delete row from datagridview with a delete button?

I've got a DataGridView with a BindingSource binding it to a DataTable. I've put a Delete button on my form and I want it to delete the currently selected row when clicked, something like this: if (dgvResourceSettings.CurrentRow != null && !dgvResourceSettings.CurrentRow.IsNewRow) { bindingSource.RemoveCurrent(); } ...

Window sliding in and out of desktop

Using .NET (if I have to use pInvoke or managed C++, that's fine too), I am trying to create a window that sort of docks or snaps to the right hand side of the desktop (like a rectangular strip like the gadget area but a real window). Secondly I want a pushpin-like thing that lets the window slide in and out (like the Windows in VS do) ...

Check SuspendLayout

Is there a way in C# to check if an object is suspend? I have a TreeView that I need to know if it is still suspend. myTreeView.BeginUpdate(); myTreeView.SuspendLayout(); // Do Stuff. myTreeView.EndUpdate(); myTreeView.ResumeLayout(); Because i have this code in a recursive function I want to know if the TreeView is already be...

Why does impersonating a process return "The directory name is invalid"?

I have a process that needs to run under administrative privileges. I need the average joe to run the process, but I don't want to give everyone access... so I've created a simple class that will run this ONE task as an administrator, using impersonation. The code is VERY striaght-forward, but I can't understand why this is crashing. HE...

Windows Forms: using BackgroundImage slows down drawing of the Form's controls

I have a Windows Form (C# .NET 3.5) with a number of buttons and other controls on it, all assigned to a topmost Panel which spans the whole Form. Eg the hierarchy is: Form -> Panel -> other Controls. As soon as i assign a BackgroundImage to the Panel the Controls draw very slowly. I have the same effect if i use the Form's BackgroundIm...

Why does calling form.Hide() cause flicker, but form.Close() not?

I have a .net form that is created in Excel (I don't know if that's relevant), and when I call form.Hide(), Excel flickers briefly. If I instead call form.Close(), the flicker is absent. Why does the Hide() version cause flicker, while the Close() version not? ...

alternative to DataGridView in Win API

Somewhere on net on one Blog I read a sentence that is "DataGridView something like Boeing 777, but what is goal when I do not know how to fly. Before I goo deep in creating my projects I wanna know is there alternative for DataGridView in C#. Something like jQuery in WEB api. The favors things which I am looking for is that is simple f...

Folder browse dialog with checkboxes?

I'm looking for the easiest solution to implement a folder browse dialog with checkboxes in front of the directories in my (C#) WinForms project. I saw this kind of dialog in Vista in the backup center. It was just like a normal Folder browse dialog, but in front of every folder there was a checkbox. If you checked a folder, all folders...

datagridview with comboboxes

I have created two classes: public class Params : List<Param> { } public class Param { public enum enType { Integer, Double, String, DateTime } private string sName_m; public string Name { get { return sName_m; } set { sName_m = value; } } private string...

How to change the color of progressbar in C# .NET 3.5?

I'd like to do two things on my progress bar. Change the green colour to red. Remove the blocks and make it in one color. Any information about those two things I wonder how to accomplish will be greatfuly appreaciated! Thanks. ...

How might I insert some JavaScript into the document of a WebBrowser control?

I'm using the System.Windows.Forms.WebBrowser control in a .NET 2.0 application, and would like to insert a bit of JavaScript code into the loaded document right before the end of the body element. How might I go about accomplishing this? ...

How to send Email from windows application in c#?

I am working MS C# 2008. I created Windows form application. And I need to send email from my application. so how do I configure smtp settings? EDIT I got The following Exception The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at on ...

Deriving from a Form class in .NET

Theoretically you can derive from a Form but is it something you should not do? I intuitively think so but I've never heard of any rule like this. Edit: of course I meant some conrete class that already derives from Form. For example if I've got class MyForm : Form, the question is can i derive from MyForm? ...

DataBinding a DataGridview rows BackColor

I have a DataGridView that uses databinding, with manually created columns, and this works fine. However I want the rows' BackColor to be databound as well, and so far my attempts have hit errors. This is my latest attempt: dataGridFileTransfer.RowHeadersVisible = false; dataGridFileTransfer.AutoSizeColumnsMode = DataGridViewAutoSizeC...

ReportViewer Conditional Formatting

I am trying to apply conditional formatting of certain table cells in my ReportViewer control. I understand how to apply conditions by comparing data that resides in the same row, for example, the following will color a cell RED if the Cost is higher than the revenue: =IIf(Fields!Cost.Value > Fields!Revenue.Value, "Red", "Black") My ...

Transparent Winform with image

I have an image (PNG file) that has an alpha channel that is set to 50% opaque. When I try to draw the image on a form that has the TransparencyKey set to white, and the backcolor set to white I expect the image to be drawn 50% see-through. However, it is being blended with the forms backcolor first and as a result it is completely opaqu...

Passing Object from Form to Form

I have a fairly large CRUD winform app that is set up to display forms embedded in tabcontrols. I want to have objects for Person,(has a) Enrollment,(has a) Plan that hold and track the information as they interact with the forms. How do I accomplish this? I found a suggestion to declare the Person object in my Program.cs like so --> ...

Delete selected row from a DataGridView

Hello, I have a DataGridView which is bound to a collection of objects. I want to make a Delete button on a form so a user could delete selected row. But there is a problem if a new row (the special last row in the grid) is selected. If I select the new row and then try to click Delete button, the grid loses its focus and changes the ...

Control a Winforms tooltip's location

Is there any way to control a tooltip's location on a Winform? I can handle the Popup event, but in the event handler I can only change the size, not the location. I could use the OnMouseEnter/Leave events of the control to manually show a tooltip, but then I lose the benefits of the AutomaticDelay property of a normal tooltip. ...

How to add unbound check box column to WinForms DataGrid (.NET 1.0, 1.1)?

How to add unbound check box column to databound DataGrid (WinForms .NET 1.0, 1.1)? I cannot add fake column to the data source because it is data view coming from elsewhere. ...