.net

Why use a owner window in MessageBox.Show?

MessageBox.Show has forms like MessageBox.Show( ownerWindow, .... ). What do I gain by assigning a owner window? ...

How do I pass in an owner window to MessageBox.Show on a different thread?

I am trying to figure out Messagebox( ownerWindow, ... ). Using reflector I see that the ownerWindow defaults to the ActiveWindow for the thread. So the only time I need the ownerWindow parameter is to call Show from another thread. However when I try this, I get a cross threading exception. private void button1_Click( object s...

Visual Inheritance or a User Control?

I have several forms in a .net windows app that have a common set of textboxes and other user input controls,each form has the same look and feel, but each form needs to load and save to different database tables. Would it be better to place the controls on a base form, and inherit from it or to create a user control to drop on each f...

Saving XML-Data in UserSettings

Hi all, I'm trying to save some XML-Data in my UserSettings (Properties.Settings.Default.UserSettings) in a .NET Winforms Project. Is there a Possibility to do that or would it be better to save this Data in a seperated File? Thanks for your Answers! ...

What is a component

I listen to the podcast java posse, on this there is often discussion about components (note components are not (clearly) objects). They lament the fact that Java does not have components, and contrast with .NET that does. Components apparently makes developing applications (not just GUI apps) easier. I can figure from the discussion...

Is LINQ to SQL InsertOnSubmit() subject to SQL Injection Attack?

I have code like this: var newMsg = new Msg { Var1 = var1, Var2 = var2 }; using (AppDataContext appDataContext = new AppDataContext(ConnectionString)) { appDataContext.CClass.InsertOnSubmit(newMsg); appDataContext.SubmitChanges(); } After reading this post I believe that the same logic applies. Does anyone think that...

Progress button for Windows Forms

.NET newbie here... I'd like to make a button in a Windows form that displays a progress or "cooldown" effect. That is, when the button is pressed, it becomes disabled. As some event or timer is progressing, the button shows the progress graphically. When the progress is finished, the graphic completes and the button becomes enabled. ...

Can you write a block of c++ code inside C#?

I heard somewhere that you can drop down to C++ directly inside C# code. How is this done? Or did I hear wrong? Note: I do not mean C++ / CLI. ...

How do you find the base url from a DLL in C#?

From within a DLL that's being called by a C#.NET web app, how do you find the base url of the web app? ...

What's the best way to use SqlBulkCopy to fill a really large table?

Nightly, I need to fill a SQL Server 2005 table from an ODBC source with over 8 million records. Currently I am using an insert statement from linked server with syntax select similar to this: Insert Into SQLStagingTable from Select * from OpenQuery(ODBCSource, 'Select * from SourceTable') This is really inefficient and takes hours to...

Change a Window background color, given a IntPtr handle

In c#, I have a handle to a window ( an IntPtr ), I want to change the background color of that window. How can I do this? I can get the GDI graphics object for that handle like so: Graphics graphics = Graphics.FromHwnd(theHandle); So I should somehow be able to change the background color from this? I also want to ensure the backgr...

Is there a sorted collection type in .NET?

I'm looking for a container that keeps all its items in order. I looked at SortedList, but that requires a separate key, and does not allow duplicate keys. I could also just use an unsorted container and explicitly sort it after each insert. Usage: Occasional insert Frequent traversal in order Ideally not working with keys separate ...

How can you see the sql that is causing an error on SubmitChanges in LINQ to SQL?

I've got some LINQ to SQL that sometimes throws a "Cannot insert duplicate key row in object 'dbo.Table' with unique index 'IX_Indexname'.The statement has been terminated." Is there some way I can turn on logging or at least debug into the datacontext to see what sql is being executed at the time that error is raised? Update: ...

How to navigate between fields with Enter Key

My company has a large application written in VB6, and for historical reasons, the application is navigated with the Enter key instead of with the Tab key. I don't know VB6, but I know that they currently set the focus for each control in a big select statement in the Form's KeyUp event if it's an EnterKey. Now we are starting to conve...

.NET 2.0 WinForm: Supporting DPI and Default Font Changes

So I'm trying to figure out how the Form's AutoScaleMode property can possibly help to support a system with a font or DPI that is different from my work development machine. From the SDK: AutoScaleMode Enumeration public enum AutoScaleMode None Automatic scaling is disabled. Font Controls scale relative to the ...

Any insight on Microsoft's new M programming language?

Does anyone have any insight on microsoft's new M programming language? Why? What type? When? What? ...

Can you mix .net languages within a single project?

Can you mix .net languages within a single project? So pre-compiled, I would like to call classes and methods of other source files. For both web and apps? In particular I'd be interested in F# and C#. ...

Drop Down List with WPF Menu Controls

Hello, I am looking for a way to add a drop down list in WPF to a menu. This used to be really easy in winforms and so I am expecting you experts to know just now to do it in WPF. Thanks. Sorry if this is a bad question, it is late and I don't want to think. ...

Open source OCR

Is there any open source OCR library written in .NET, or written in any language but can be used in an ASP.NET application? ...

Reflection and generic types

I'm writing some code for a class constructor which loops through all the properties of the class and calls a generic static method which populates my class with data from an external API. So I've got this as an example class: public class MyClass{ public string Property1 { get; set; } public int Property2 { get; set; } public boo...