.net

Is it legal to quote from the Microsoft Reference Source or from reflected BCL code?

I've noticed that some questions here on StackOverflow (example) are answered by quoting either some part of the .net Reference Code or some decompiled parts of the .net base class library (using Reflector). On one hand, the MS Reference Source License does not allow redistribution of the code "outside your company", and I'm pretty s...

Multicolumn ListBox control

I'm looking for a free ASP.NET 2.0 ListBox control that supports display of items in two columns. It also needs to support selecting multiple items. I really prefer not to have to use a monospaced font and mess with formatting my ListBox items into columns. I also saw suggestions to use other types of controls (such as a DataList) but...

Form must be convertible to System.Web.UI.Page

I was making changes in my .aspx file, when IntelliSense complained: "LSPForm must be convertible to System.Web.UI.Page". Here's the @Page line I'm using: <%@ Page AutoEventWireup="true" Codebehind="LSPForm.aspx.cs" Inherits="LSPForm" Language=""C#" MasterPageFile="MasterPage.master" Title="DMV: Marker Plate Notice" %> The code-behi...

accessing a subarray in vb.net (or the equivalent)

I read a an array of bytes from a file I pass this to a class that then assigns various bytes from that array to various members of varying sizes. Ideally i would like to do something like this memberThatIsAUShort = bitconverter.ToUShort(tempArray.subArray(3,5)) memberThatIsAShort = bitconverter.ToShort(tempArray.subArray(6,8)) Inste...

Formatted string parsing and updating

I need to replace specialy marked place holders in string with values. Similar to what string.Format does, but in a bit more advance way. For instance: input string: "Welcome to {Binding Path=@city}!" Value for @city is "Boston" Output string should be "Welcome to Boston!". I can successfully parse input string with regex and get th...

Missing resource runtime exception when form tries to load picturebox

Hey guys. I'm trying to put a picture in one of my forms. I dragged a picturebox onto the screen and clicked "Choose Image" and picked my image from the dialog box. When I run it, however, I get a runtime error: An unhandled exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll Additional...

Where would be the best place to start in C# without buying a book?

Hi, I am very strapped on cash and I do not want to buy a book, but what tutorial site will teach me the best for C#. I plan to use it with the .NET framework and design some web applications. I am going to be using visual studio and I have good experience with OOP and java. I just have no idea where to start with getting everything s...

width of the dropdown arrow

So in winforms, every dropdown combobox has this little arrow thingy to the right that tells the user it's a dropdown, kinda like this: Now how do I figure out how wide that is in pixels? Reason is, I'm using ControlDrawToBitmap, this doesn't draw the text properly for the combo boxes, and I can redraw the contents, I just whack some ...

.net Remoting: Detect if a server isn't running

I'm working on an app that uses .net remoting for IPC. When my client app starts up, it uses the following code to connect to the server: chnl = gcnew HttpChannel(); ChannelServices::RegisterChannel(chnl, false); IPCObjectInstance = (BaseRemoteObject)Activator.GetObject( typeof(BaseRemoteObject), "http://localhost...

How to write every time to a new row of data table?

How can i insert each time a diffrent row in datatable? The data table is used in a dataGridView to write a log. I need each time to write in a diffrent line (row) in the datatable, when I can't know how many rows I need in runtime. Another thing; the datatable is loaded from a XML file, so there might be already rows in the data table. ...

Proper way to pass username/password to SmtpClient (.NET)

The question is too simple, but still appreciate the short answer. I would like the SmtpClient to fetch username/password from the App.config file. From the MSDN/schema I've figured out that the proper file (excerpt) should look like: <system.net> <mailSettings> <smtp from="[email protected]"> <network host="mail...

.NET Deflate Stream Error/Bug

Has anyone experienced the following error while using the .NET Deflate Stream? System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.IO.Compression.HuffmanTree.CreateTable() at System.IO.Compression.Inflater.DecodeDynamicBlockHeader() at System.IO.Compression.Inflater.Decode() at System.IO.Compres...

Binding a method that returns List<employee> to a gridview

Hello, I have method in my N-Layered application that returns List. Below is the sample code for the method public List<employee> GetAllemployees() { List<employee> empl =new List<employee> empl=DAL.GetEmployees(); return empl; } Now I have a gridview in my aspx page and how do I set the gridview datasource as GetEmployees() ...

Method with Predicate as Parameter

This is a general question, but here is the specific case I'm looking for a solution to: I have a Dictionary<int, List<string>> I want to apply various predicates to. I want one method that can take care of multiple LINQ queries such as these: from x in Dictionary where x.Value.Contains("Test") select x.Key from x in Dictionary where ...

.net photo select 'wand' functionality

Is there any way using .net I can emulate the wand functionality found in your normal photo editor? I.e. user clicks on part of a photo and the application automatically selects the surrounding X pixels based on a given factor (usually tolerance threshold). Any idea on how I could do this with .net? Thanks ...

Can the .NET Stopwatch class be THIS terrible?

I'm making an app that needs some pretty tight timing and the Stopwatch class is the perfect solution. However, I noticed sometimes, when running on a small panel PC, the Stopwatch values veer way off. I added some debug printouts that monitor the value of the stopwatch every 200 ms or so: 0:00:197 0:00:502 0:00:702 ... 0:03:...

purpose of ConnectionString element in .NET .config files

What is the difference between storing and reading your application's connection string in the <appSettings> and <connectionStrings> sections of web.config? ...

Prevent databind on Gridview when clicking the Edit template link

My Gridview is refreshing its datasource when the edit button is clicked. How can I prevent this from happening? This isn't much of a problem when there aren't a lot of records, but when there are many it takes awhile. The data is already loaded so the edit button shouldn't need to reload the data. The edit button is a template edit ...

Code clarity for converting generic list?

This code should convert the list of listType2s (list) to a list of type1s. I feel the functionality is somewhat difficult to ascertain though. I am looking to see alternative methods that are easier to read, yet concise, and brief. List<Type1> type1s = new List<Type1>(); listType2s.ForEach(t => type1s.Add((new Type1(t...

VisualStudio Default Code Discovery Method

A little while back (after recently installing VStudio 2010) I used the Go to Definition... feature and a little box opened up asking me if i wanted to: Use the object explorer Open Meta-Data View Something I can't remember Well I wasn't really paying much attention and selected meta-data view, I'd now like to set it to Object Explor...