winforms

Prevent a textbox from scrolling when adding text

I'm adding new logs line to a WinForms TextBox object, and this causes the textbox to scroll to the bottom. How can I prevent this and retain my current position? (a short code snippet would help) ...

Timer cannot be stopped in C#

Hello all, I have a timer on a windows form (C# 3.0, .net 3.5 SP1, VS2008 SP1, Vista) that seems to work even after it is stoppped. The code is: using System; using System.Windows.Forms; namespace TestTimer { public partial class Form1 : Form { public Form1() { InitializeComponent(); Sta...

How do I set the GroupBox caption colour

On my system, the caption of a groupbox is always a dark blue colour, how do I change this? The answer to How do you change the color of the border on a group box? shows how I can override the drawing of the caption and border, but I don't want to have to deal with Visual Styles and drawing rounded corners and the like. ...

How do I set the Font color of a label to the same as the caption color of a GroupBox?

I want to have some labels on a form with the same font color as the caption on my group boxes, and furthermore I want these colors to change if the user has applied a different Theme on their system. Can I do this without changing the GroupBox caption from its default? UPDATE: I have tried setting the Label ForeColor to ActiveCaption...

Cursor disappearing in winforms (C#)

I have a problem with the cursor in my winforms app. When I press a button on the form, the cursor disappeares for a short period of time (1-3 sec.) Any ideas? Could this be caused by a backround worker interfering with cursor = cursors.waitcursor call? ...

WinForms Events for Inheriting Controls for UI Style

Follow up to this question: http://stackoverflow.com/questions/553518/winforms-style-ui-look-and-feel-tips So I have created my "base controls" from which other controls inherit from. For testing, I am trying to change one of the base label's font. But it is not propagating to the controls that inherit from it. On one of the forms, I c...

.NET - Visible screen rectangle of nested control

Hi all, having a nested control somewhere inside a scrollable control, how can I determine the currently visible screen rectangle of this control? (see image below) --> Image My intention is to use ControlPaint.DrawReversibleFrame (which needs screen coordinates), but only draw on the visible region of the nested control. Thanks for ...

Iterate thru DataRepeater (VB.Net PowerPack)

I am using the winform datarepeater control from vb.net power pack. All of the items on the repeater are readonly except for a checkbox column. I want to iterate over the items and find out which checkboxes are checked. I can't find a collection of datarepeateritems on the control and help is scarce. Thanks for the help. ...

C# how to disable webbrowser usage

I have a C# application that has a webbrowser and need to be able to completely disable it at times. What is the best method of doing this? I was thinking about creating a transparent panel to put over the webbrowser when needed, but am not sure if this is the best approach. I also noticed that C# doesn't easily allow making a panel t...

How to create a transparent control which works when on top of other controls?

I have a control (derived from System.Windows.Forms.Control) which needs to be transparent in some areas. I have implemented this by using SetStyle(): public TransparentControl() { SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.BackColor = Color.Transparent. } Now, this works if there are no controls between...

how to work with multiple coincident panel controls in VS 2008 windows forms

in VS 2008, I am attempting to design a windows form that is similar to a set of property pages but uses a TreeView to select the page rather than a TabControl. An example of this design is the Options dialog in VS 2008 itself. There are two reasons I want to do this: 1. I prefer the look and feel; 2. I want to give users the ability...

How can I create different cell formats in Winform DataGridView C#

I have a DataGridView that I'm binding to a DataTable. The DataTable is a all numeric values. There is a requirement that every n rows in the DataGridView has text in it, rather than the numeric values (to visually separate sections for the user). I am happy to put this text data in the DataTable or in the DataGridView after binding, ...

Detecting changes to a bound datatable after validation

Here is the scenario: I have a winform with bound controls to a datatable populated by a db proc call. The user makes changes to the data in the form control. They click a "save" button on that form. I want to be able to detect that the data actually changed and call a proc if true. I want to do this with ADO.net, not a homegrown dir...

Masked TextBox, how to include the promptchar to value?

How to include the prompt char on masked textbox's Text? I also want to save the prompt char Example i specify mask: &&&&/&& And prompt char of _ Then I enter 12 4/5. the program should save it as 12_4/5. Anything left blank should be converted to prompt char when getting the masked Textbox's Text [EDIT] Found it, set TaskMaskF...

ListView Cursor changing & flickering

I'm trying to change the cursor that appears on a standard ListView when the cursor appears over an item. However I am getting a flickering effect as the mouse is changed to a finger cursor, and then back to what I asked it to be. I'm trying to isolate this flicker/changing to the hand cursor but can't figure out where it's occuring or ...

Am I missing something with my ListView selection event handling...

...or are c# listviews really such a nightmare to manage? Okay the problem I'm working on is very simple. Or at least it appears to be so: I have a text file which contains information about customer orders on separate lines. The data items are separated by semi-colons. My form iterates through these orders, puts the item information ...

What's the "right" way to isolate control dependencies

I've made it a personal rule to inherit every UI control before using it. In a previous life I'd always considered this one of the less useful things you could do because the justification always seemed to be "I might want to change the font on all the buttons at once"... a motivation that never paid off... once... ever. Two recent pro...

Adding design-time support for a nested container in a custom/usercontrol (Winforms).

Hi I have something similar to a wizard control, in the middle is a Panel I would like to use to place any child controls. I have found using the ScrollableControlDesigner will allow dropped controls to be added to the custom/usercontrol, but this is not what I require. It needs to be added to the container, so layout can be applied wi...

WinForms: How to custom draw using the selected RenderMode?

I have some custom controls that will require custom painting. I cannot use any of the drawing services available in Windows (e.g. ThemeAPI), since .NET applications ignore look-and-feel of the operating system they are on, and instead use their own look and feel. e.g. Toolbars are not the toolbar common control Status bars are not t...

WinForms App Data Caching - In Which Layer to Cache?

We have data that's updated nightly in a database residing in the same instance as my app's database. So to save on database calls, I want to cache this static-for-the-day data into a List(Of MyObject). From a theory point of view, should this cached List(Of ) be cached in the presentation layer code, via a global variable? Should it be ...