Why are some textboxes not accepting Control + A shortcut to select all by default

You might be looking for the ShortcutsEnabled property. Setting it to true would allow your text boxes to implement the Ctrl+A shortcut (among others). From the documentation: Use the ShortcutsEnabled property to enable or disable the following shortcut key combinations: CTRL+Z CTRL+E CTRL+C CTRL+Y CTRL+X CTRL+BACKSPACE CTRL+V CTRL+DELETE CTRL+A SHIFT+DELETE CTRL+L SHIFT+INSERT CTRL+R However, the … Read more

Combine Multiple Predicates

How about: public static Predicate<T> Or<T>(params Predicate<T>[] predicates) { return delegate (T item) { foreach (Predicate<T> predicate in predicates) { if (predicate(item)) { return true; } } return false; }; } And for completeness: public static Predicate<T> And<T>(params Predicate<T>[] predicates) { return delegate (T item) { foreach (Predicate<T> predicate in predicates) { if (!predicate(item)) { … Read more

Workaround for lack of ‘nameof’ operator in C# for type-safe databinding?

This code basically does that: class Program { static void Main() { var propName = Nameof<SampleClass>.Property(e => e.Name); Console.WriteLine(propName); } } public class Nameof<T> { public static string Property<TProp>(Expression<Func<T, TProp>> expression) { var body = expression.Body as MemberExpression; if(body == null) throw new ArgumentException(“‘expression’ should be a member expression”); return body.Member.Name; } } (Of course … Read more

Displaying thumbnail icons 128×128 pixels or larger in a grid in ListView

For update: Set image list color depth in addition to image size (ilist.ColorDepth = ColorDepth.Depth24Bit) WinForms ListView does not have possibility to change icon spacing, however it can be easily done using Win32. You need to send LVM_SETICONSPACING to your ListView (there is a lot of tutorials how to use SendMessage win32 function in .net, … Read more

Convert bitmaps to one multipage TIFF image in .NET 2.0

Start with the first bitmap by putting it into an Image object Bitmap bitmap = (Bitmap)Image.FromFile(file); Save the bitmap to memory as tiff MemoryStream byteStream = new MemoryStream(); bitmap.Save(byteStream, ImageFormat.Tiff); Put Tiff into another Image object Image tiff = Image.FromStream(byteStream) Prepare encoders: var encoderInfo = ImageCodecInfo.GetImageEncoders().First(i => i.MimeType == “image/tiff”); EncoderParameters encoderParams = new EncoderParameters(2); … Read more

How do I send ctrl+c to a process in c#?

Despite the fact that using GenerateConsoleCtrlEvent() for sending Ctrl+C signal is the right answer, it needs significant clarification to get it to work in different .NET application types. If your .NET application doesn’t use its own console (Windows Forms/WPF/Windows Service/ASP.NET), the basic flow is: Attach the main .NET process to the console of the process … Read more

Get DateTime For Another Time Zone Regardless of Local Time Zone

In .NET 3.5, there is TimeZoneInfo, which provides a lot of functionality in this area; 2.0SP1 has DateTimeOffset, but this is much more limited. Getting UtcNow and adding a fixed offset is part of the job, but isn’t DST-aware. So in 3.5 I think you can do something like: DateTime eastern = TimeZoneInfo.ConvertTimeBySystemTimeZoneId( DateTime.UtcNow, “Eastern … Read more

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