TableLayoutPanel displays vertical scroll

The problem concerns TableLayoutPanel scrolling. You have to use a Panel for scrolling instead of TableLayoutPanel. Here is an example to solve this problem (for vertical scrolling) : Set your TableLayoutPanel properties as follow : Dock = DockStyle.Top AutoSize = true AutoSizeMode = AutoSizeMode.GrowAndShrink AutoScroll = false. Put your TableLayoutPanel into a Panel with properties … Read more

Const function parameter in C# [duplicate]

Update 16/09/2020 There now appears to be the in parameter modifier that exhibits this behaviour (in essence, a ref readonly). A brief search on when you would ever use this yields the following answer: Why would one ever use the “in” parameter modifier in C#? Original Answer There is no equivalent for C# and it … Read more

Boiler plate code replacement – is there anything bad about this code?

This is good stuff. Make them extension methods though to clean up your code a little more. For example: //Replaces OnMyEventRaised boiler-plate code //Usage: SafeInvoker.RaiseEvent(this, MyEventRaised) public static void Raise(this EventHandler eventToRaise, object sender) { EventHandler eventHandler = eventToRaise; if (eventHandler != null) eventHandler(sender, EventArgs.Empty); } Now on your events you can call: myEvent.Raise(this);

Run async method 8 times in parallel

I coded it in the assumption that asynchronous and parallel processing would be the same Asynchronous processing and parallel processing are quite different. If you don’t understand the difference, I think you should first read more about it (for example what is the relation between Asynchronous and parallel programming in c#?). Now, what you want … Read more

Complex “Contains” string comparison

You could use an appropriate CompareInfo and then CompareInfo.IndexOf(string, string, CompareOptions) and check the result against -1. Sample: using System; using System.Globalization; class Program { static void Main() { var compareInfo = CultureInfo.InvariantCulture.CompareInfo; var options = CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreNonSpace; var haystack = “bla Lé OnAr d/o bla”; var needle = “leonardo”; var index … Read more

Memory usage in C#

If you want the memory of the entire running process and not on a per thread basis, how about: // get the current process Process currentProcess = System.Diagnostics.Process.GetCurrentProcess(); // get the physical mem usage long totalBytesOfMemoryUsed = currentProcess.WorkingSet64; There’s a whole host of other process memory properties besides WorkingSet64 check out the “memory related” ones … Read more

TreeView, HierarchicalDataTemplate and recursive Data

You should only have to declare the HierarchicalDataTemplate for NodeViewModel as this is the only thing showing in the TreeView, and bind the actual ItemSource to the TreeView <TreeView ItemsSource=”{Binding Items}”> <TreeView.Resources> <HierarchicalDataTemplate DataType=”{x:Type local:NodeViewModel}” ItemsSource=”{Binding Children}”> <TextBlock Text=”{Binding Name}”></TextBlock> </HierarchicalDataTemplate> </TreeView.Resources> </TreeView> Full Example Xaml: <Window x:Class=”WpfApplication13.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:local=”clr-namespace:WpfApplication13″ Title=”MainWindow” x:Name=”UI” Width=”343″ Height=”744.625″ … Read more