Quantcast
Channel: C# – Monkey Can Code
Browsing latest articles
Browse All 21 View Live

C# – using Attributes

Attributes in C# is used to embed custom metadata about the code / class in the code. Microsoft has a very good example on how to write your own custom attribute class:Microsoft Custom Attribute...

View Article



C#: dynamically add a context Menu in run time

The following code can add a context menu as well as the code that gets executed when you click on Context Menu Item in run time.Normally, you design the context menu by using the Visual Studio IDE....

View Article

C#: how to write in-line code in new Event Handler Declaration

Normally, you need to declare a new Event Handler and give this new event handler a name, then write the function inside the new event handler function to complete the code. However, you can skip that...

View Article

C#: set the form’s ICON to the Application Icon

If you would like to set the icon of a windows form to be loading from the Application itself. Use this in your code:   this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);

View Article

C#: Simple way to parse XML string to get Value from the tag

C# makes it very easy to parse a xml file or string. For example, if you want to parse the following xml file, looking just for the value of the tag called “score”: <?xml version=”1.0″...

View Article


C#: Simple Way to Upload a File

In this example, I will show you how to easily upload a file to your web server via FTP. You’d need to add using System.Net; Make a FTP connection and read a file into stream, then writes to FTP....

View Article

C#: Update UI Component with Threadsafe Operation

Sometimes when you try to access UI component from a different thread, you’ll run into exception on you can’t access UI component from a different Thread than the original UI thread that creates the...

View Article

C#: Use Design Time Property in a User Component

Normally, you can not set design time property within a user control. Design time means when you drag and drop a user component on your windows form, you can see the properties grid, that allow you to...

View Article


C#: Passing data to BackgroundWorker DoWork Event

Normally, you call the RunWorkerAsync() without an argument to start the background worker. Sometimes you might want to pass some data into the DoWork() function. All you have to do is simply do:...

View Article


C#: Export DataGridView to Microsoft Excel

It’s fairly easy to export all the records that are on your Data Grid View to Excel. The code below shows you how to Run Microsoft Excel Interop and go through each rows and columns in data grid view,...

View Article
Browsing latest articles
Browse All 21 View Live




Latest Images