Geeks With Blogs
Jim Lahman's Blog Fortitude|Endurance|Faith|Teamwork April 2009 Entries
C# string formatting
In C++, one uses the sprintf function to build a formatted string like this: char szOutput[256]; sprintf(szOutput, "At loop position %d.\n", i); The C# equivalent is the String.Format method [string.format(string, object)]. TrkCmnRec.szMillOrderNbr = String.Format("MO #{0}", i); Each placeholder in the string is numeric, so if we want to have a string with three placeholders, we would use {0}, {1}, {2},...{n} as shown in this example: String sA = "Test string" int i = 10; Single f = 45.0 String s ......

Posted On Monday, April 13, 2009 3:56 PM

Using win32 API in C#
When I was working in VC++, it was relatively easy to include a win32 API function. All we did was include the header file and then made a call to a function like so: #include <Mailbox.h> CMailbox::MbxStatus CMailbox::iCreateMbx() { MbxStatus iStatus = mbxSuccess; switch ( m_iType ) { case mbxReceiver: case mbxBoth: // for receive type mailboxes we need to create a // space for the reception of data /* if ( m_hRecvMbx ) CloseHandle( m_hRecvMbx ); */ m_hRecvMbx = ::CreateMailslot( m_strInName, ......

Posted On Tuesday, April 7, 2009 9:51 AM

Adding items to a listview in C#
I created a listview with two columns as part of a text C# solution to test the use of structures. This list was created with the IDE. When creating a list where you want to show multiple columns, set the listview's view property to Details. I use the IDE to define the columns by selecting columns from the properties list. To fill in the listview before displaying it, I programmatically add the items in the form's LOAD event. BTW, I'm moving from VB.Net to C# and adding events to the form is different ......

Posted On Sunday, April 5, 2009 4:50 PM

Copyright © Jim Lahman | Powered by: GeeksWithBlogs.net