Showing posts with label VS 2005. Show all posts
Showing posts with label VS 2005. Show all posts

Wednesday, July 11, 2012

Reading a Lotus Notes Mail Box



You need the Lotus Domino Objects to be added into your application. Refer: http://www.ibm.com/developerworks/lotus/library/domino-msnet/

You need to know the Path of your Lotus Notes Mail-box:

 
Domino.NotesSession s = new Domino.NotesSession();
            Domino.NotesDatabase db;
            Domino.NotesView vw;
            Domino.NotesDocument doc;

            try
            {
                //Leave blank Password, then It will prompt for Password, It basically authenticates with the *.id file
                s.Initialize("mypassword");

                //If Server is blank, which Local otherwise specify the Server
                //Place the Mailbox path Next
                db = s.GetDatabase("", @"C:\Documents and Settings\me\Local Settings\Application Data\Lotus\Notes\Data\mail\me\mymailbox.nsf", false);
                if (db != null)
                {
                    //Inbox is special/hidden folder
                    vw = db.GetView("($Inbox)");
                    doc = vw.GetFirstDocument();

                    while (doc != null)
                    {
                        String Subject = ((object[])doc.GetItemValue("Subject"))[0] as String;
                        String From = ((object[])doc.GetItemValue("From"))[0] as String;

                        textBox1.Text += Subject;
                        textBox1.Text += From;
                        doc = vw.GetNextDocument(doc);
                    }
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
 
 
Additional Resources:









Tuesday, May 22, 2012

Having Text and Image in One Single Column of DataGridView


DataGridView's Cell_Painting event could be utilized to achieve the above. You need a DataGridView and ImageList in which an Image to be attached. The following simple code in event will be able to achieve this:

private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
 {

    if (e.RowIndex >= 0 && e.ColumnIndex == 0 && Convert.ToInt32(e.Value.ToString()) > 0)
    {
        e.PaintBackground(e.ClipBounds, false);
       dataGridView1[e.ColumnIndex, e.RowIndex].ToolTipText = e.Value.ToString();
       PointF p = e.CellBounds.Location;
       p.X += imageList1.ImageSize.Width;

      e.Graphics.DrawImage(imageList1.Images[0], e.CellBounds.X, e.CellBounds.Y, 16, 16);
       e.Graphics.DrawString(e.Value.ToString(), e.CellStyle.Font, Brushes.Black, p);
       e.Handled = true;
    }

}
 
Refer DataGridView FAQ in the following Thread:
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/b5ab78d6-a760-4f29-ac89-46bad51ba30a







Installing the Visual Studio 2005 Image Library

The Visual Studio 2005 Image Library is copied to your computer when you install Visual Studio. To access the files in the image library, you must extract them from the file VS2005ImageLibrary.zip.

To install the Visual Studio 2005 Image Library

  1. Locate the file VS2005ImageLibrary.zip. This file is normally installed in \...\Program Files\Microsoft Visual Studio 8\Common7\VS2005ImageLibrary\.
  2. Right-click VS2005ImageLibrary.zip and click Extract All.
    The Extraction Wizard appears.
  3. Follow the directions in the wizard to extract the images.
Refer MSDN Link

Thursday, July 21, 2011

Default Values via BindingSource's AddingNew Event

I new that BindingSource's AddingNew event can handle all default value assignment, but was so frustrated that I could not find any articles/tutorials which guided me on how to use it. Although MSDN had description, but it did not have samples on how to use it. However, with few long hour searches I came to a source which enlighted me on how to use this event.

A sample code looks like this:
 
private void branchBindingSource_AddingNew(object sender, AddingNewEventArgs e)
{

//// Get data table view 
DataView dataTableView = branchBindingSource.List as DataView;


//// Create row from view
DataRowView rowView = dataTableView.AddNew();


rowView["BranchID"] = -1;
rowView["BranchCode"] = "001";
rowView["BranchDescription"] = "002";

//// Set New row
e.NewObject = rowView;

branchBindingSource.MoveLast(); 

}



 
 


Thursday, October 28, 2010

Opening a Solution Causes VS 2005 to crash and restart

Earlier today, I had to include a code snippet to my project. Unrealizing the consequences it might result in, I went ahead compiling and got an error message saying “Object reference not set to an instance of an object” and finally my VS 2005 crashed. This error message keeps on greeting every time to I tried to reopen the project.

Being clueless of what has gone wrong, I googled tirelessly to find a solution to overcome this problem, but without a joy.

While this error message keeps on coming, I try to realize that my VS were actually running on debugging on all of my Windows forms. Since the Code snippet I included was to my base form’s shown event, so every time I reopen VS 2005 it opens this Windows Forms and sends this error message.
In the Error Signature I witnessed the following:

AppName: devenv.exe
AppVer: 8.0.50727.42
AppStamp:4333e699
ModeName: system.design.ni.dll
ModVer: 2.0.50727.3053
ModStamp:4889df30
fDebug:0
Offset: 006b8532

I came across an article on running devenv.exe in “Visual Studio 2005 Command Prompt” and was enlightened me that I could build, rebuild, clean…etc project and its files. So I went to Visual Studio’s Project folder and located the *.cs file which was giving the error and edited via Notepad. Then I deleted the code snippet that was the causing the problem and replaced by a simple “Hello World” message box. Finally I build the project by trying my luck via VS 2005 Command Prompt by running the following commands:


devenv [either *.csproj or *.sln file of your project] /clean


devenv [either *.csproj or *.sln file of your project] /build

devenv [either *.csproj or *.sln file of your project] /rebuild


and it worked! I was finally able to open the project via Visual Studio and it worked well… No errors!