I am trying to programmatically change the ForeColor and BackColor properties of subitems in a listview. Why doesn’t this work
Make sure the item’s UseItemStyleForSubItems property is set to false. ListViewItem item1 = new ListViewItem(‘item1’,0); //this line makes things work item1.UseItemStyleForSubItems = false; //set fore & back color of next sub item item1.SubItems.Add(‘1′, Color.Black, Color.LightGreen, Font); item1.SubItems.Add(’44’); item1.SubItems.Add(‘3’); //As long as UseItemStyleForSubItems is false, you can later set the colors with code such as item1.SubItems[2].BackColor = Color.Pink;
How can I convert an Enumeration member to string and vice-versa
To convert an enum to string, do this: string enumEntryAsString = Enum.GetName(typeof(TabSizeMode), TabSizeMode.FillToRight); To convert a string to an enum type: // Enclose this code within try/catch. TabSizeMode sizeMode = Enum.Parse(typeof(TabSizeMode), ‘1’); (or) TabSizeMode sizeMode = Enum.Parse(typeof(TabSizeMode), ‘FillToRight’);
Whenever I share files between projects it appears that Visual Studio.NET copies the files over into the new project. I want to just share the file and not have it copied over. Is there any way to do this
When you add an existing item from with the Visual Studio.NET IDE, click the small arrow on the ’Open’ button in the dialog that is presented. You will see a list of options. One of these is to ’Link file’. If you select this option then you will not get a local copy and any changes that you make to the linked file will be in the original file. Another way to get the same effect is to share the files using Visual Source Safe. You can simply drag and drop the files between projects in VSS and they will also be in sync.
How do I use an exported function (extern ‘C’) from a legacy DLL
Use the DllImport attribute that is a member of the System.Runtime.InteropServices namespace. Assume your exported function found in MyDLL.dll has a signature: int MyFunction( LPCTSTR lpCaption, UINT uType); The code below shows how you can access this function from within C#. using System; using System.Runtime.InteropServices; class HelloWorld { [DllImport(‘mydll.dll’)] public int MyFunction(string title, int type); public static void Main() { int nReturnValue = MyFunction(‘some string’, 14); } }
How can I implement VS.NET type menus
Carlos Perez provides sample code at codeproject.com.