winforms

Call a web service from a Windows Application

I am new to .NET and C#. I created a Web service, and I am able to view it from a Web page. When I try to call it from a Windows Application, I get the Exception 401 : unauthorized. Code compiles OK, but throws exception when running. This is the code from the Windows App. : namespace BookStore { public partial class Form1 : Form ...

Best way to databind a group of radiobuttons in WinForms

I'm currently working on databinding some of my existing Windows Forms, and I've ran into an issue figuring out the proper way of databinding a group of radiobutton controls within a group box. My business object has an integer property which I want to databind against 4 radiobuttons (where each of them represents the values 0 - 3). I'...

data binding update when value changes, not when tabbing out

Is there a property or setting to force a bound control in Winforms to update the object it is bound to when the input value, either in a textbox or whatever, actually changes? And not after the control is tabbed out of. ...

Subclassed Textbox readonly font not recognized on form

Building my baseclasses for user interface controls is getting there. I have command buttons derived with custom font assignment and put on a form, all is fine... However, identical code for the read-only property Font of a textbox is NOT recognized properly on the same form. It is ONLY taking the setting of the FORM and disregarding i...

opening forms in c#

Hi, I had a button in first form .if i click the button the second form is opening ,if i click again same button in first form another second form is opening.i need to open only one second form only in c# . ...

focusing forms

Hi, If i click button event in form1 form2 should be focus, if i click button event in form2 form1 should focus in c# How can I do this ? ...

WM_DESTROY, WM_CLOSE bypassing IMessageFilter

Below is my message filter: bool MyFilter::PreFilterMessage(Message %m){ switch(m.Msg){ case WM_CLOSE: case WM_DESTROY: case WM_NCDESTROY: case WM_QUIT: Debug::WriteLine(L"Gone!"); break; case WM_MOUSEMOVE: Debug::WriteLine(L"A mouse! Catch! Catch!!! CATCH!!"); break; } return false; }...

Add and remove the UserControl dynamically

Hi, I have UserControl that holds Infragistics Graph control. On the TreeView sub node's right click, I have context menu as "Create Graph". This will create the new graph. This is about what i going to do. I have confusion about what layout to use. Whether FlowLayoutPanel or TableLayoutPanel or anything else. If only one graph is add ...

Microsoft Active Accessibility in C#

Does anyone have any pointers on where to start with this? I'm using MS UI Automation to do some acceptance testing of an application, but the MenuStrip control doesn't support MSUIA, and apparently the only way to get what I want from it is Active Accessibility (MSAA). Sadly, there appears to be very little available on how to act as ...

Generic base class for WinForm UserControl

I created a generic base class for a WinForm UserControl: public partial class BaseUserControl<T> : UserControl { public virtual void MyMethod<T>() { // some base stuff here } } And a UserControl based on that: public partial class MyControl : BaseUserControl<SomeClass> { public override void MyMethod<SomeC...

Good examples of Winform UIs - from a UX and aesthetic standpoint

Can anyone recommend some good online resources that show samples of what would be considered good Winforms "design" in terms of both User Experience and overall aesthetics. I'm looking for something that includes screenshots so as to inspire me..... not just a bullet list of best practices. Thanks! ...

C# TreeView.GetNodeAt() problem with clicking images.

Hi. I'm using the click event on the TreeView to do some stuff when a node is clicked in the TreeView. I do this by getting the node that is click on by calling GetNodeAt() with the mouse coordinates, like this: private void TreeView_Click(object sender, System.EventArgs e) { MouseEventArgs mouseEventArgs = e as MouseEventArgs; ...

C# / Windows Forms - How can I determine if someone is currently "Dragging"? (not in DragOver event)

Assuming that I'm in a function that is called in a Timer on in Windows Forms class... how can I tell if the user is currently attempting to "Drag" something? example: public void SomeMethod() { // This doesn't exist of course :) if (Mouse.IsDragging) ... } EDIT: I should specify that I know that I can override DragEnter and ...

Dynamically Populated TableLayoutPanel Performance Degredation

I have a user control that contains a 2-column TableLayoutPanel and accepts commands to dynamically add rows to display details of an item selected in a separate control. So, the user will select a row in the other control (a DataGridView), and in the SelectedItemChanged event handler for the DataGridView I clear the detail control and ...

removed event but still firing

I'm having a strange bug where an undesired event is firing. I can trace into the code and see that the "onRowLeave" event handler is being removed using the -= syntax, then the next line a DataSource is changed which causes the "OnRowLeave" handler to fire! So it seems the removal is not working. I can tell it's not being added in ag...

Why DataBinding doesn't work on second time around?

The error I got when I change the datasource of BindingSource "databinding cannot find a row that is suitable for all bindings row that is suitable for all bindings" this.RemoveAllBindings(); // My work-around for the meantime bdsOrder.DataSource = _ds.Tables["orders"]; // errors here on second time around(first time i...

Using keyboard shortcuts with LinkLabel controls

I've noticed that keyboard-shortcuts assigned to linklabel controls in standard .NET WinForms forms are not functioning. I have created a LinkLabel control instance and assigned the Text property to be "Select &All". For most controls (label, button, radio button, etc) this would cause Alt-A to become the designated keyboard shortcut to...

Winforms multithreading scenario question

Hello, this morning I saw some strange code from one of my coworkers. In an winforms application the whole Mainform was given into a thread as reference. He did this to invoke methods from the Form. Nothing to interact with the UI, just plain calculation methods. I am already sure this is not a best-practice but I wonder something. If I...

How to update datagridview

I am working in c# project, i need to update datagridview control after inserting a new record. When i am doing this, the gridview keeps its old values also, what should i do to show only updated records ...

How to make a window always stay on top in .Net?

I have a C# winforms app that runs a macro in another program. The other program will continually pop up windows and generally make things look, for lack of a better word, crazy. I want to implement a cancel button that will stop the process from running, but I cannot seem to get the window to stay on top. How do I do this in C#? E...