winforms

Simple databinding - How to handle bound field/property change. Winforms, .Net.

I have a custom control with a bindable property:- Private _Value As Object <Bindable(True), ... > _ Public Property Value() As Object Get Return _Value End Get Set(ByVal value As Object) _Value = value End Set End Property Any time the field, that Value is bound to, changes, I need to get the type. I ...

Problem deleting multiple rows in an unbound datagridview

Hi: I am a programmer teaching myself C#. I have a project that reads rows from an SQL database and displays them in a datagridview. That part works great. I want to show a subset of these records by deleting every non selected row in the grid. This is the code: foreach (DataGridViewRow row in dataGridView1.Rows) { if (!row.Selected...

How do I get/set a winforms application's working directory?

To get the Application's root I am Currently using: Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase).Substring(6) But that feels sloppy to me. Is there a better way to get the root directory of the application and set that to the working directory? ...

Creating a Windows Forms Control (C++)

trying to run this basic form control example on msdn. At step 1 of the portion "To add a custom property to a control" we place the ClickAnywhere code in the public section of the class. First error: "error C2144: syntax error : 'bool' should be preceded by ';'" Is this syntax correct in C++? (see below) (removing the ClickAny...

Am I responsible for Disposing a BackgroundImage?

Hi, I have a windows form where I set the BackgroundImage property to a custom bitmap image. private Image MakeCustomBackground() { Bitmap result = new Bitmap(100, 100); using(Graphics canvas = Graphics.FromImage(result)) { // draw the custom image } return result; } private void UpdateFromBackground() { ...

Interface coding issue

i am sending a value(attrname[5] = "WRM Version";) from SendAgentInfo() from a.dll It is received in sp.dll as WrmVersion.From here i am sending those values in to an interface(IResourcePolicy) located in data.dll.But the problem is data is not getting interface 'IResourcePolicy',,if it is recieved in Interface,it should display in a LI...

ToolStrip Buttons flashes

Hi, I have a windows form with a toolstip in it with several buttons. When the mouse is over a button of the toolstip then the toolstrip button starts to flash... looks like it gets and loses focus every second. That results for the click to do nothing if the user click at the time that the button has no focus therefore the user has to...

Refreshing BindingSource after insert (Linq To SQL)

I have a grid bound to a BindingSource which is bound to DataContext table, like this: myBindingSource.DataSource = myDataContext.MyTable; myGrid.DataSource = myBindingSource; I couldn't refresh BindingSource after insert. This didn't work: myDataContext.Refresh(RefreshMode.OverwriteCurrentValues, myBindingSource); myBindingSource.Re...

MS Chart Control axis formatting

I'm using the MS Chart Control in a Winforms app I'm writing. The X-axis component of the scatter plot I'm displaying is Int64 data, which ultimately represents a UTC time. I'd like to take that Int64 data and essentially do a DataTime.FromFileTimeUTC(theTime).ToString() on it to show the end-user X-axis labels that are meaningful. Cu...

How can I prevent a Checkbox state switch when the user clicks on the text?

Hi, I have a list box with Checkboxes in it. I want to prevent the Checkbox from changing its status if the user clicks on the text next to it. I only want it to change if the small box is clicked directly. Is there any way to do this in windows forms? Greetings and thanks in advance. ...

Stop controls from being painted

I have a User Control that has some WinForm Controls inside. I want to be able to paint those inner controls myself (for scrolling purposes, some of them will remain, others will move). Even when I override the OnPaint and the OnPaintBackground method, those controls keeps showing on my usercontrol which is completely black now because...

Retrieve value of most recently SelectedItem from multi-select listbox

How can I retrieve the value of a clicked item in a multi-select listbox? Currently, if I click one item and use lstBox.SelectedValue, it will return the proper value; however, if I then click on another item, I am still shown the first item's value. Basically, I want the value of the item most recently clicked on, regardless of whet...

How can I catch scroll events in windows forms PropertyGrid

I'm trying to synchronize the vertical scrollbars of two property grids. The idea is when a user scrolls one property grid the other property grid scrolls by the same amount. My first approach was to handle the scroll event but it seems PropertyGrid doesn't generate this kind of event. I looked into the controls contained inside the Pro...

Implementing multiple screens in an Application

Weird question, but one that puzzles me a bit. In the old days when we had Terminals and DOS, applications generally only had one "window", and that was a fullscreen one. When people switched functions, there was no concept of opening a new window, but instead the content of the main window was overwritten. So there was only one main win...

Anti-Aliased Text in a Transparent .NET Form

I have a C# application which shows the current time in a transparent .NET Form. The Form has no controls and no border. Its property TransparencyKey is set to the Form's background color "light gray" to make it transparent. So the user can only see the text (current time). The text is drawn in the PaintEventHandler: private void Dis...

Create google maps trip from a .NET win-app?

Hello. I have a win-application that needs to reproduce a trip for a trucker according to a list of addresses. I was doubting if it's possible to open a browser and transmit the addresses to the google-maps website so it creates the journey for me? If the answer is no, I would you suggest to do it, if I don't have any website, I want ...

Changing the BackColor of my custom UserControl - help!

Hello my kind sirs. (lol) I have a panel on Form1. I'm going to add several instances of my custom usercontrol MovieItem to that panel. To do this I'm going: panel1.Controls.Add(objMovieItem); Now, within the MovieItem.cs code I'm adding the .Click events of everything inside the UserControl so that whenever a user clicks ANYWHERE i...

Split button in .NET Winforms

I'm looking for a Split Button in .NET WinForms. The kind where one side is a button and the other side has a dropdown button. I see them used all over in windows, like in the Visual Studio Save As window, so I figured they've got to have the control in some library. I know there's one for toolstrips, but I need one thats usable out...

Stackpanel with widthstyle set to fill?

I am in a situation where I want to add usercontrols in a panel. This has to be in a topdown order. I have done whats explained here to make it act like a stackpanel. However I want the width of each usercontrol to fill out the panel and not be a fixed size. I tried using tablelayoutpanel and setting it grows attribute to 'add rows' bu...

Problem with text input in textbox control

I'm working in a WPF project, which basically is a class library project that implements the MVVM pattern. For clarity purposes I'm gonna say that I just have a single window with a single textbox control on it. Now, I'm adding this dll to another project, which is a Windows Forms project, and I'm calling the window with the textbox co...