winforms

C#: in the .NET libraries, is there a standard class that can view and print an RTF string?

C#: in the .NET libraries, is there a standard class that can view and print an RTF string? I essentially need a "viewer" which will simply display a simple or rich-text string and have a print button which would allow printing of the displayed string. ...

Move to previous textbox from current by pressing backspace

i want to know how to move the cursor from current textbox to previous textbox. i am creating textbox dynamically by enter keypress event one by one e.g. textbox1 textbox2 textbox3 suppose total three textbox now created and am on third one textbox means my cursor on textbox3 and i wants to move the cursor to textbox2 or...

fluent nhibernate ... mapping 'lookup' value to DataGrid

To make this as simple as I can think to ask, if I have to classes: Order, OrderType, where an Order has 1 to 1 relationship with OrderType, how can I Bind (List) to a datagrid, and see the desired column/field from OrderType? When I bind a List to a datagrid, in the Order.OrderType 'field', I just get the name of the OrderType class w...

Update DatagridView Cell Background color based on row data

Hi I got a DatagridView and I would like it to change background color depending on the data in each row. Ex. | Person 1 | Person 2 | Person 3 | |----100----|---200-----|-----150----| |----300----|---100-----|------50----| In the first row I would like it to make "100" have a red background color and "200" green. Or. The lowest val...

Capitalization/Naming Convention for Controls

Hello, What is the best and recommended practice regarding capitalization for naming controls in, for example, WinForms? StyleCop says that instances of classes should start with a lower case letter. I respect this convention in my code. In previous languages that I have used, for example VB6, I have been used to name my UI controls d...

Reflection and attributes -- removal? modification? OR windows service in full trust?

I want to remove the security permissions from a class I don't have access to the source for. Is it possible to, via reflection, remove or modify the attribute? [...PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust"), PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")] after some consideration, it's occurred to...

How do I get custom dialog close without showing graphics artifacts?

I have a custom windows modal form with the following event code: private void btnCancel_Click(object sender, EventArgs e) { Close(); _result = DialogResult.OK; } The problem is when I click OK, that triggers some process-intensive stuff (report generation) and the form becomes partially drawn on the screen. It's like the report ...

Simple app with timer is eating memory away ?

Hi, Can anybody explain why this tiny app's memory usage keeps increasing ? static class Program { private static System.Timers.Timer _TestTimer; [STAThread] static void Main() { _TestTimer = new System.Timers.Timer(); _TestTimer.Interval = 30; _TestTimer.Elapsed += new System.Timers.ElapsedEven...

.Net Treeview Event Handling

I am in the process of migrating a VB6 app to .Net and we must provide like-for-like functionality at all times. In one form is a treeview with checkboxes that has three levels of nodes. The first level serves only to group the next level down and they are not checkable. The second level nodes are checkable by the user and when checked o...

Adding a help window to an application - C#

Hello, I've already searched on SO to see if there has been a similar question but I haven't found anything so far. I'm looking to add a help window to my application, similar to the ones found in many other applications (Example below): As you can see the help window allows you to give plenty of instructions for particular function...

Third party controls for a radio button list in WinForms?

Are there any controls that can dynamically create a group of radio buttons from a list of objects? Something similar to the CheckedBoxList control, but with mutually exclusive selection. This question points out this control doesn't exist natively for WinForms but are there any third party controls that do this? ...

how to move tool strip to right end of a form?

I have a Tool strip in which i need to add some buttons. When i drag this tool strip on the form it is at the top of the form but i want this tool strip at the right end of the form. How to do it? ...

Realtime filtering of listbox

I would like to be able to filter a listbox containing 1000 strings, each 50 - 4000 characters in length, as the user types in the textbox without a delay. I'm currently using a timer which updates the listbox after the TextChanged event of the textbox has not been triggered in 300ms. However, this is quite jerky and the ui sometimes f...

DataGridView Place a frozen column to the far right

I have a DataGridView in a WinForms 2.0 App that has a lot of columns, enough that even when maximized the user has to scroll to see all columns. The far right column is a delete button. We want to always display the delete button without the user having to horizontally scroll. When I try setting column.Frozen = true; it removes my ho...

Setting the ReadOnly property on derived DataGridViewCells

This is either me not understanding the order of constructor execution or not understanding the precedence of ReadOnly fields on DataGridViews. class Form1 : Form { public Form1() { DataGridView gv = new DataGridView(); Controls.Add(gv); gv.Columns.Add("foo","foo"); gv.Rows[gv.Rows.Add()].ReadOnly...

Menu is getting hidden

I have a blank form with a design time menu in it. now at run time I load a form which is a VC 6.0 DLL into this form, so it should fill all the area of the form, which it does but it is also causing the menu to be hidden. but I do not want that... I want to still be able to see the menu and rest of the form area to be filled by that For...

DataGridView Sort repositions the horizontal position of grid slightly

I have a DataGridView with a lot of columns which causes a horizontal scrollbar. However, when I scroll all the way to the right and sort on a column the datagridview slightly repositions itself, but the scrollbar remains all the way to the right. I want to stop this behavior and keep the grid in the same position it was in before the ...

Speeding up listbox insertion time

I need to add 950 strings that are 2500 characters in length to a listbox. The method I am using below takes 2.5 seconds and ideally it needs to happen in less then 500ms. Stopwatch sw = Stopwatch.StartNew(); listBox1.BeginUpdate(); listBox1.Items.AddRange(items.ToArray()); listBox1.EndUpdate(); sw.Stop(); What would be the best wa...

Dynamic Control PositionScrolling Issues

I'm creating dynamic controls in a Form and I made a static button to add fields within a panel. When fields are added this button is relocated to be underneath these added lines. But when the button reaches the low end of the panel (having autoscrolling set to true) it disappears and scrolling becomes infinite downwards. So this behavio...

How to Detect Enter Key press in a text box which is used in a Custom View??

I have made a custom view in which i have used a search box which is a text box to search specific directory.When we press Enter key on the search box i search the directory and if found then refresh my custom browser to dispaly the new diretories content. but the problem is when i am in modal dialog then i could not detect the Enter ke...