Monday, 1 September 2014

If string is not null or empty else

string.IsNullOrEmpty(someString) ? "<NULL>" : "<not NULL / Empty>";

Tuesday, 15 July 2014

How to hide Close (x) button for Windows Forms?


Method 1
 
this.ControlBox=false;


Method 2

private const int CP_NOCLOSE_BUTTON = 0x200;
protected override CreateParams CreateParams
{
    get
    {
       CreateParams myCp = base.CreateParams;
       myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON ;
       return myCp;
    }
}

Tuesday, 1 April 2014

Configure Internet Explorer to open Ms Office (Word,Excel,Power Point Etc)documents

Method 1



Open My Computer and On the Tools menu click Folder Options.







Click the File Types tab.In the Registered file types list, click the specific Office document type (for example, Excel), and then click Advanced .









In the Edit File Type dialog box, click  the Browse in same window check box .and click clear other check box


Click OK 2 times.


private void Form1_Load(object sender, EventArgs e)
{
    webBrowser1.Navigate(@"C:\sample.xls");
}

Friday, 21 March 2014

textbox password Rebuild

if (cshowPassword.Checked != true)
{
      txtPassword.PasswordChar = '*';
}
else
{
     txtPassword.PasswordChar = char.Parse("\0");
}

Thursday, 20 March 2014

Unexpected Error creating debug information file ***.PDB



Answers (This worked for me:)
  1. Shut down VS.NET
  2. Browse to the project in Windows Explorer   
  3. Delete the /obj/ folder.
  4. Delete the project outputs (.dll and .pdb) from /bin (not sure if this step is necessary)
  5. Can't hurt but might help: delete the project outputs from any other project /bin folders in the solution that is having issues (wasn't necessary for me)
  6. Restart VS.NET
  7. Rebuild