Posts

C# - ListView Item Spacing (Padding)

I'm perplexed at the reasoning that the ListView control, has no direct spacing/padding property. I am utilizing the ListView in the capacity of images, using the View state, View.LargeIcon. There is a method to modify the spacing/padding between the ListViewItem(s). Initially, you'll need to add: using System.Runtime.InteropServices; Next, you'll need to import the DLL, so that you can utilize SendMessage, to modify the ListView parameters. [DllImport("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); Once completed, create the following two functions/methods: public int MakeLong(short lowPart, short highPart) { return (int)(((ushort)lowPart) | (uint)(highPart << 16)); } public void ListViewItem_SetSpacing(ListView listview, short leftPadding, short topPadding) { const int LVM_FIRST = 0x1000; const int LVM_SETICONSPACING = LVM_FIRST + 53; SendMessage(listview.Ha...

Converting VS 2010 Solution to VS 2008

If you ever need to convert a Visual Studio 2010 Solution to a Visual Studio 2008 Solution, you know there is no native conversion support. When helping someone on the codeguru forums , I found this code project solution, to help them, and thought I should share it with everyone. Please check out the solution here . Enjoy.

C# / ASP.NET - Getting an IP Address

If you are attempting to get an IP address, from a system connected to your ASP.NET page, or just trying to pull up a local IP address, the following code block can be used. The GetHostAddresses method queries a DNS server for the IP addresses associated with a host name. If the system has IPV6 enabled, and you are trying to pull the IP address, simply using GetHostAddresses won't work, as it will return the IPV6 address. This code should generate your IPV4 address. // using System.Net; (Required) protected string GetIPAddress() { string IPV4Address = String.Empty; foreach (IPAddress IPAddr in Dns.GetHostAddresses(HttpContext.Current.Request.UserHostAddress)) { if (IPAddr.AddressFamily.ToString() == "InterNetwork") { IPV4Address = IPAddr.ToString(); break; } } if (IPV4Address != String.Empty) return IPV4Address; foreach (IPAddress IPAddr in Dns.GetHostAddre...

SSRS : Changing PC Name

If you are using SQL Server Reporting Services (SSRS) as a reporting solution, and must change your device's PC name, SSRS may not correctly generate and display reports once the computer has been renamed. To correct this, perform the following steps: Open the Reporting Services Configuration Manager. Click the Database Tab. Modify the existing database, and simply follow the prompts. Once the procedures and steps are completed, try to re-run your Reports.

C# / XNA - Error - XNA Framework HiDef Profile

When creating an XNA game, and the application produces the following error, your video card does not support the current version of DirectX. In this case, the requirement is video card support for pixel shader 4.0 . No suitable graphics card found. Could not find a Direct3D device that supports the XNA Framework HiDef profile. Verify that a suitable graphics device is installed. Make sure the desktop is not locked, and that no other application is running in full screen mode. Avoid running under Remote Desktop or as a Windows service. Check the display properties to make sure hardware acceleration is set to Full. If your video card does not support pixel shader 4.0 , you can toggle the game profile, from HiDef to Reach . To modify this, go to project properties , XNA Game Studio , and toggle the radio button, Use Reach to access a limited API set supported by Windows Phone, Xbox 360, and Windows.

SSRS - Troubleshooting Errors

When attempting to duplicate a Report Server, from one system to another, you may encounter an issue that the keys do not match. The report server is unable to access encrypted data. Apply a back-up key or delete all encrypted content. (rsEncryptedDataUnavailable) (rsRPCError) To resolve the error, open the Report Server Configuration Manager , and select the Encryption Keys button on the sidebar. Back up encrypted keys from the primary server, transfer and load into current system. When attempting to restore a Report Server, when launching the reports you may encounter the following error message: The report server installation is not initialized. (rsReportServerNotActivated) (rsRPCError) To resolve the error, delete Keys table from the ReportServer database, then Stop and Start the Reporting Services, from the Report Server Configuration Manager , which will auto-create the system keys on the restart of the service.

C# / XNA - Device Enumeration

Graphics cards support a variety of resolutions, refresh rates, and aspect ratios. In order to determine which display modes are available. The following function generates these display modes, and enters them into a List of type DisplayMode . List dmList = new List (); public void GetDeviceEnumeration() { foreach (DisplayMode dm in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) dmList.Add(dm); } Once the List of DisplayMode s is obtained, simply iterate through the available display modes, and populate some sort of user interface control, such as a listbox, combobox, etc, allowing users to select which resolution they want to use. The following options can be accessed through the DisplayMode: Width, Height, AspectRatio, and Format. Width: Available Screen Width. Height: Available Screen Height. Format: Available Surface Format. (Commonly used: COLOR , and BRG565 .) Aspect Ratio: Common Aspect Ratios below, Regular and Widescreen. Widescreen ...