How to get Windows native look for the .NET TreeView?

You need to P/Invoke to call SetWindowTheme passing the window handle of the tree and use “explorer” as the theme. Paste the following code into a new class in your project, compile, and use this custom control instead of the built-in TreeView control. C#: public class NativeTreeView : System.Windows.Forms.TreeView { [DllImport(“uxtheme.dll”, CharSet = CharSet.Unicode)] private … Read more

Using an array as argument for string.Format()

You can convert int array to string array as pass it using System.Linq Select() extension method. infoText.text = string.Format(“Player1: {0} \nPlayer2: {1} \nPlayer3: {2} \nPlayer4: {3}”, place.Select(x => x.ToString()).ToArray()); Edit: In C# 6 and above, you can also able to use String Interpolation instead of using string.Format() infoText.text = $”Player1: {place[0]}\nPlayer2: {place[1]} \nPlayer3: {place[2]} \nPlayer4: … Read more

C# “is” operator – is that reflection?

Referencing ECMA-335, the is operator generates the isinst object model IL instruction (Partition III §4.6), which is part of the base instruction set as opposed to being part of the Reflection library (Partition IV §5.5). Edit: The is operator is extremely efficient compared to the reflection library. You could perform basically the same test much … Read more

Getting “” at the beginning of my XML File after save() [duplicate]

It is the UTF-8 BOM, which is actually discouraged by the Unicode standard: http://www.unicode.org/versions/Unicode5.0.0/ch02.pdf Use of a BOM is neither required nor recommended for UTF-8, but may be encountered in contexts where UTF-8 data is converted from other encoding forms that use a BOM or where the BOM is used as a UTF-8 signature You … Read more

Unable to install or run the application: Click Once

I found solution here: “Unable to install or run the application. The application requires that the assembly be installed in the Global Assembly Cache (GAC) first.” Excerpt from wordpress link: I recevied this error while compiling my first C# production application. I had to do the following in Visual Studio for the project: In Solution Explorer, … Read more

Delegate caching behavior changes in Roslyn

Yes. The most important part is that the method containing lambda implementation is now an instance method. You can see a delegate as a middleman receiving an instance call through Invoke and dispatching that call according to the calling convention of the implementing method. Note that there are platform ABI requirements that specify how arguments … Read more

winforms html editor [closed]

You can use the WebBrowser control in design mode with a second WebBrowser control set in view mode. In order to put the WebBrowser control in design mode, you can use the following code. This code is a super stripped down version of a WYSIWYG editor for one of our software products. Simply create a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)