winforms

Loading an XML document and displaying it in a tree view

I have to load an Xml document and display in a tree view in a winform. here is a piece of code. Please tell whats the error. private void AddingNodesToTree(ref XmlNode xnode, ref TreeNode tnode) { TreeNode subNode = treeNodes.Add(xnode.Name); subNode.Tag = xnode; foreach (XmlNode subElement in xnode.ChildNodes) { ...

Error in code: Loading of XML document

Hello, this is in reference to a question asked earlier. Here is the complete code and it's giving me an error: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Xml; using System.Text; using System.Windows.Forms; using System.Collections; using System.IO; ...

Why all the different collections in Winforms?

If I would like to display 10 000 items in a combobox (just an example), loading a List from disk is fast, but when I set the DataSource it's slow. Is there a way to just point to the data and not convert it into the combobox collection. List<string> myitems = getItems(); ComboBox box = new ComboBox(); box.DataSource = myitems; ...

Reasons for why a WinForms label does not want to be transparent?

Why can't I set the BackColor of a Label to Transparent? I have done it before, but now it just don't want to... I created a new UserControl, added a progressbar and a label to it. When I set the BackColor of the label to transparent it is still gray =/ Why is this? What I wanted was to have the label on top of the progressbar so that ...

Updating multiple selected INofityPropertyChange objects in DataGridView

Hi all I'm working with a DataGridView (Windows Forms) with MultiSelect enabled which is placed in a User Control. I'd like to update all selected rows from outside the User Control by calling a public method that implements the following code: foreach(DataGridViewRow dr in dataGridView.SelectedRows) { MyBusiness business = (MyBusi...

How to pass string parameter of a method from one class to another class in same namespace?

Hi Friends, Little silly question, but got stuck for a long time. I have written two classes one which is a Form (TreeDisplay class) and other which contains buiseness logic (MyTreeNode class). TreeDisplay class contains browse button to select a file pass it to a method initiatingTree(string filename) which is in MyTreeNode class. No...

Checking two dozen values, textboxes against datacolumns, algorithmically.

Okay big brains here's something that's more of a challenge than a requirement. I am a bit stumped. I usually just need a prod in the right direction, so get your prodding sticks ready. I have a tabcontrol covered in textboxes. I want to perform a check of the contents of all the textboxes during the SelectedIndexChanged event on a list...

Databinding a Custom Control

I have a Custom Control (Windows Form) that is a lookup text box. A property on the Control is Current Selection which is a Custom Object containing "Identifier", "Code" and "Description". This property is Databound using a BindingSource. Displaying the information works great. On the other hand regardless of whether I set the Update to...

C# Threads and this.Invalidate()

Hi! I'm developing a Windows Mobile app (Compact Framework 2.0 SP1) and this code it's generating me an error: public Image Imagen { get { return imagen; } set { imagen = value; this.Invalidate(); }...

Winforms .Net Simple Databinding Not Working

I have a Winform with a very basic premise: modify 2 string properties of an object that is passed into it, then save it to disk when the form closes. I am trying to use databinding to bind the Text properties of 2 textboxes on the form to the 2 string properties of the object. But it isn't working. The textboxes never display the value...

How do you open the event log programatically?

I'm logging errors to the event log using the usual: System.Diagnostics.Trace.TraceError("<" + purpose + "><time>" + DateTime.Now.ToUniversalTime() + "</time><message>" + message + "</message></" + purpose + ">"); and am wondering if there is a way to call this log file and display it for the user (either in my own format or by openi...

Custom Caret for WinForms TextBox

Hi, I'm developing a custom HyperTerminal like application in a WinForms .Net 2.0 application. I have a multiline TextBox in a Panel in which you can interact with a hardware device. My customer wants to have a custom Caret, a filled rectangle the size of one character space instead of the vertical line that is by default. I know .Ne...

How do I paint a hosted NumericUpDown using the existing ToolStripRenderer?

I have a control which hosts a NumericUpDown in a ToolStripControlHost and exposes the NumericUpDown's properties. Functionally, that's fine, but when it's placed on a ToolStrip it doesn't fit visually with the other ToolStripItems. I'd like to use the ToolStrip's existing ToolStripRenderer to draw the control in a manner similar to th...

Listening to Events in Main Form from Another Form in C#

I have an application that has a main form and uses an event handler to process incoming data and reflect the changes in various controls on the main form. This works fine. I also have another form in the application. There can be multiple instances of this second form running at any given time. What I'd like to do is have each insta...

Validate on text change in TextBox

I have implemented validation rules on a textBox in my WinForm and it works well. However it checks the validation only when I tab out of the field. I would like it to check as soon as anything is entered in the box and everytime the content changes. Also I'd like it to check validation as soon as the WinForm opens. I remember doing th...

winforms panels vs java swing panels

In java swing I can insert panels into panels and so on, and not have to build a brand new window for every view of my applicaiton, or mess around removing and adding controls. Theres a panel clas sin C# however I cant see any way of creating a 'panel form' or basically just a form in form designer thats a panel and its contents. How d...

Highlighting two child controls simultaneously

I have a windows form with two child controls. I need to highlight both the controls at the same time using c#. Please suggest me how to solve this problem. ...

Windows Forms / Winforms C# development - what should I do?

I am trying to get a new contract/job and virtually everything out there (UK) seems to equate .NET with ASP.NET - and that's not me. Sorry if this seems a little rambling but I really am wondering "What next?" I'm a Window Forms developer, used to doing the whole thing from design through to delivery/support. I've a VB background (but...

Need to mousewheel scroll a usercontrol.

I have a usercontrol I created. I added a panel and a vertical scrollbar to the right of it. I'd like to be able to scroll it with the mousewheel. The problem is there doesn't seem to be any events that fire on mousewheel. If I take the panel off then the usercontrol has focus and it will fire on mousewheel in the form. But with the...

Acting only on text input in a KeyPress Event

I have a key press event, and I want the combobox to handle the keypress if the input is not textual. I.E. If it is the up or down key, let the combobox handle it like it normally would, but if it's punctuation, or alphanumeric I want to act on it. I thought Char.IsControl(e.KeyChar)) would do the trick, but it doesn't catch the arrow k...