winforms

How can I fix a NullReferenceException in System.Windows.Forms.ToolStripControlHost.SetVisibleCore ?

When setting control visibility I sometimes get this: CRASH! Failed to refresh job control: Exception:NullReferenceException Message:Object reference not set to an instance of an object. Source: System.Windows.Forms TargetSite: SetVisibleCore StackTrace: at System.Windows.Forms.ToolStripControlHost.SetVisibleCore(Boolean visible)...

how to print Test-page on default Printer ?

hi how to print Test-page on default Printer using C# Winform Code ? thank's in advance ...

Winform / Group Box ?

I drew a Group Box around a bunch of controls cause I wanted to the Box, meanwhile all the controls are glued to the Group Box. How can I remove the Group Box without removing the Controls? ...

How to rotate a list of strings along an axis?

Hi, I have a list of strings which I paint on an axis. I want to rotate the strings (again, they should stay on the same horizontal axis when rotated). I am trying to use the following code: namespace DrawString { struct StringData { public string StringName; public int X; public int Y; } public...

Can I display a form on top of or beside the Windows Vista Login screen?

I have a need to display alerts and such on-screen at any time the computer is running. We have a service running collecting these events, so that's not a problem - but I need to find a way to display critical alerts, even if the user hasn't logged in yet; that is, they're sitting at the 'Press Ctrl-Alt-Delete to log in' prompt. Is this...

Windows form/WPF too large, how can i split it up?

Hello people, I'm about to create WPF application. So far at uni the only way we have ever done GUIs is to have one main window with one code-behind file for handling its button clicks etc.. My issue is that as the application grows, the GUI grows, and the size of the code behind file can get really out of hand! I have identified abo...

How to draw a single line using MouseMove Event

Hi guys, I'm trying to draw a single line using OnMouseMove() event. My Problem is that everytime I move the mouse It leaves a trail. I tried to use the refresh method, but when I stop moving the mouse the line is gone. I don't want the line to be drawn OnPaint();, Just want to draw it OnMouseMove(). EDIT: I'm using a transparent pan...

WPF and Silverlight dead ?

There is a lot of talk in the twitterverse today that WPF is dead and Silverlight has a bleak future, and that HTML5 is crowned new UI king. One such article here with further links. The problem I have with this, is that's all very well for WEB Dev but what about Windows Applications, what next for us? Do we go back to (or stay with) W...

Binary numbers only TextBox

I want to validate the input of a TextBox to be a binary number. I know I can do this with RegEx but I wanted a more 'inmediate' validation, like allowing just 1's and 0's to be entered. I thought of using MaskedTextBox but I don't know how to just allow those two characters. ...

Import excel sheet data to datagrid without using oledb

In my Windows based application(C#) i want to import excel sheet to show its data in DatatGridView i dont want to use oledb any Help ...

How to lock/Unlock a windows application form in C#

I need to lock the entire form if the execution of a perticular process is in progress. My form contains many controls like buttons, comboboxes. all the controls should be in disabled state if the process is running Now i'n using the two methods from user32.dll [DllImport("user32.dll")] public static extern IntPtr FindWindow(S...

How to attach popup winform at main form's custom postion ?

Hi, I have a C# winform main application running hosting main form. now i want to popup a small winform to show some status but it should lock itself to mainforms to the center of title bar. now I want it to stick there for some duration till i close it from code. it should not take focus (i guess it is not mdi so this should be default...

c# form losing focus

Hi When i run my application with visual studio IDE, the application runs fine. When i run directly the executable it is not running fine. My app creates two forms. First form losts focus when the second form is about to create. The first form UI frezzes when i run directly executable. Please give any suggestions how to debug the pro...

Winforms Double Buffering

I added this to my form's constructor code: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); But it still shows ugly artifacts when it loads the controls, whenever they change (the form is a calendar, it changes often). What do I need to do differently? ...

how to insert null or empty string to datetime var ?

hi i get data from xml file and sometime the date is empty. i have this code: try { TimeTo = Convert.ToDateTime(R[15].ToString()); } catch { TimeTo = null ; } but i got error because i cant insert null to datetime var what i can do ? thak's in advance ...

Same C# code slower in ASP.Net application versus Winforms App on same machine

We have a function in C# that uses the ICSharpCode SharpZipLib BZip2 decompression method to uncompress some XML we get from a database. We have noticed an issue on two of our webservers (Win 2K and Win 2003 Svr) that this code takes a really long time to execute and causes the CPU utilization to max out on these servers. We have isolate...

Linq to XML returning me a subset of my input xml

I have an XML like below :- <SourceXML> <Issue ID="123"> <Fields> <Number>5</Number> </Fields> </Issue> <Issue ID="125"> <Fields> <Number>8</Number> </Fields> </Issue> <Issue ID="127"> <Fields> <Number>11</Number> </Fields> </Issue> </SourceXML> I have to get all the Issue nodes which have number as 11 or 8(where clause filter) I tri...

Display error if a treeview root node contains a child node

I am having a treeview initially with a root node when form is loaded. I will add child node as some.txt file at the runtime by selecting an option as Addnew from contextmenu which was displayed when the user right clicks on the root node. Now what i need is if the tree has child node appended to the Root and if user tries to create a ne...

Run-time creation of Visual Studio form designer source code

I'm refactoring a program containing a lot of forms created dynamically from run-time informations. To reduce the level of complexity of the system, I thought to write individual code files for each of these forms. Since the forms are many, I'm thinking for a way to automate the process of creation of the forms source code files from ...

Adding Items To A ListView From A Different Thread? (Cross-thread operation not valid)

I'm trying to add items to a list view in a different thread than it was created in and am getting a cross-thread error. How can I make this element accessible in other threads? ...