Aug302009

Asp.net tips

Asp.net tips for improving the development performance click here to downlo...

Aug302009

Excel Data Reader - Read Excel files in .NET

Lightweight and fast library written in C# for reading Microsoft Excel files ('97-2007). Cross-platform: - Windows with .Net Framework 2 - Windows Mobile with Compact Framework - Linux, OS X, BSD with Mono 2+ cllick here to downlo...

Aug272009

How do I prevent a user from moving a form at run time?

The following code snippet shows how you can prevent a user from moving a form at run time: [C#] protected override void WndProc(ref Message m) { const int WM_NCLBUTTONDOWN = 161; const int WM_SYSCOMMAND = 274; const int HTCAPTION = 2; const int SC_MOVE = 61456; if((m.Msg == WM_SYSCOMMAND) && (m.WParam.ToInt32() == SC_MOVE)) { return; } if((m.Msg == WM_NCLBUTTONDOWN) && (m.WParam.ToInt32() == HTCAPTION)) { return; } base.WndProc (ref m); } [VB.NET] Protected Overrides Sub WndProc(ByRef m As Message) const Integer WM_NCLBUTTONDOWN = 161 const Integer WM_SYSCOMMAND = 274 const Integer HTCAPTION = 2 const Integer SC_MOVE = 61456 If (m.Msg = WM_SYSCOMMAND) &&(m.WParam.ToInt32() = SC_MOVE) Then Return End If If (m.Msg = WM_NCLBUTTONDOWN) &&(m.WParam.ToInt32()...

Aug272009

How do I make my child Form fill the entire mdi client without being maximized?

Here is how it can be done. This takes into account all docked controls (including menus) in the mdi parent form. [C#] private void FillActiveChildFormToClient() { Form child = this.ActiveMdiChild; Rectangle mdiClientArea = Rectangle.Empty; foreach(Control c in this.Controls) { if(c is MdiClient) mdiClientArea = c.ClientRectangle; } child.Bounds = mdiClientArea; } [VB.Net] Private Sub FillActiveChildFormToClient() Dim child As Form = Me.ActiveMdiChild Dim mdiClientArea As Rectangle = Rectangle.Empty Dim c As Control For Each c In Me.Controls ...

Aug272009

Avoid duplicate child form in MDI

How do I check to see if a child form is already displayed so I don't have two instances showing? // MyChildForm is the one I'm looking for MyChildForm childForm = null; foreach(Form f in this.MdiChildren) { if(f is MyChildForm) { // found it childForm = (MyChildForm) f; break; } } if( childForm != null) { childForm.Show(); childForm.Focus(); } else { childForm = new MyChildForm(); childForm.MdiParent = this; childForm.Show(); childForm.Focus();...

Aug242009

Read Pdf file using c#

So you’ll have to download the PDFBox package. In this package you’ll find a bin directory. To read your PDF file, you’ll need the following files: * IKVM.GNU.Classpath.dll * PDFBox-0.7.3.dll * FontBox-0.1.0-dev.dll * IKVM.Runtime.dll PDF Box Package is free distribution tool You’ll have to add a reference to the first two in your project. You’ll also have to copy the last two on your project’s bin directory. The program will look something like this (if you’re working with a Console application): using System; using org.pdfbox.pdmodel; using org.pdfbox.util; namespace PDFReader { class Program { static void Main(string[] args) { PDDocument...

Aug242009

read Excel file using c#

How to read an Excel file with OleDb and a simple SQL query? This approach is extremely useful when you need to read the data from an Excel file fast and store the data in a DataTable for further usage. using System.Data; using System.Data.OleDb; ... String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + [Your Excel File Name Here] + ";" + "Extended Properties=Excel 8.0;"; OleDbConnection objConn = new OleDbConnection(sConnectionString); objConn.Open(); OleDbCommand objCmdSelect =new OleDbCommand("SELECT * FROM [Sheet1$]", objConn); OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(); objAdapter1.SelectCommand = objCmdSelect; DataSet objDataset1 = new DataSet(); objAdapter1.Fill(objDataset1); objConn.Close(...

Aug222009

unicode character in C# names

You can use any unicode character in C# names, for example: public class MyClass { public string Hårføner() { return "Yes, it works!"; }...

Aug222009

Using @ for variable names that are keywords.

var @object = new object(); var @string = ""; var @if = IpsoFacto(...

Aug222009

shortcut for creating properties

Has anybody used "props"? You type "prop" and then press [TAB] twice, it generates useful code for your properties and can speed your typing. I know this works in VS 2005 (I use it) but I don´t know in previous version...

Aug222009

Bind countries from CultureInfo class in C#

Some people have asked me how BlogEngine.NET displays a dropdown list of countries when no source XML file is present. The simple answer is that you don’t need any external list to bind to from C#, you can instead use the CultureInfo class. Consider that you have the following dropdown list declared in an ASP.NET page: Then from code-behind, call this method which binds the countries alphabetically to the dropdown: public void BindCountries() { System.Collections.Specialized.StringDictionary dic = new System.Collections.Specialized.StringDictionary(); System.Collections.Generic.List col = new System.Collections.Generic.List(); foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures)) { RegionInfo ri = new RegionInfo(ci.LCID); ...

Aug222009

C# coding Standards

...

Aug222009

csharp coding style

...

Aug202009

Tabbed MDI Dock panel

It's free one ...

Aug192009

Validating ASP.NET CheckBox

...

Aug192009

Dot net cheat sheets

ASP.NET Page Life Cycle Diagram (PNG) ASP.NET Runtime Cheat Sheet Microsoft .NET Framework 3.5 Commonly Uses Types and Namespaces (PDF) Visual Studio 2005 Default Keybindings C# | VB (PDF) Visual Studio 2008 Default Keybindings C# | VB Microsoft ASP.NET AJAX Library Microsoft ASP.NET AJAX Client Life Cycle & Events (PDF) LINQ XAML/WPF VB.NET/C# Comparison SQL Server HTML Character Entities RGB Hex Color Chart CSS jQuery 1.2 | jQuery 1.3 JavaScript XHTML (PDF) Regular Expressions ...

Aug182009

html 5 cheat sheet

HTML cheat for your reference with more options ...

Aug182009

css3 cheat sheet

css3 style sheet reference for enhance web development ...

Aug182009

Difference between two dates

This snippet calculates the difference between two dates. DateTime d1 = new DateTime( 2000, 7, 13 ); DateTime d2 = new DateTime( 2003, 12, 5 ); TimeSpan s = d2 - d1; int numberofdays = s.TotalDa...

Aug182009

Ajax chat Application

This application shows how to develop a simple AJAX chat application. It uses the ScriptManager and UpdatePanel Class to get messages stored in a SQL Server database. ...

Aug182009

Visual C# 2005 Keyboard Shortcut

keyboard shorctut reference poster from Microsoft click here...

Aug182009

Dot net keyboard shortcuts

Key board shortcut keys always help to increase your speed. So i am giving below some of the Keyboard Shortcuts which will be very useful. Ctrl + N :- Opens the New Project Dialogue Box Ctrl + Shift + O :- Opens the Open File Dialog Box Ctrl + Shift + A :- Opens Add New Item window Ctrl + D :- Opens Add Existing Item window Ctrl + F :- Opens Find window Ctrl + H :- Opens Find and Replace window Ctrl + Shift + H :- Opens Replace in Files window Ctrl + Alt + Shift + F12 :- Opens Find Symbol window F7 :- Opens Code Designer window Shift + F7 :- Gets you back to Design View Ctrl + R :- Opens the Solution Explorer window Ctrl + Alt + S :- Opens the Server Explorer window Ctrl + Shift + C :- Opens the Class View window F4 :- Opens the Properties window Ctrl + Shift + E :- Opens the Resource view...

Aug172009

c# 2005 cheat sheet

cheat sheet1 cheat sheet2 cheat sheet...

Aug142009

Store Images in Database

Sample application for storing and getting images from sql server..... click here to downlo...

Aug142009

Clear all TextBox values

protected void ClearControl(Control Ctrl)//passing the control{foreach (Control eachCtrl in Ctrl.Controls)//loop taking each controls{if (eachCtrl.Controls.Count > 0)ClearControl(eachCtrl);else if (eachCtrl is TextBox)((TextBox)eachCtrl).Text = null;}}To call the method like this:ClearControl(this...

Pages 141234 »