[Solved] how to show the progress bar while loading the crystal report

Loading report is a single operation (two at most: query and displaying the viewer), so that you can’t split it do display progress accurately. You could display progressless bar or use animated image like this one: That operation has to run in parallel to UI thread (use Thread, Task or BackgroundWorker), otherwise your progress (progressbar … Read more

[Solved] Find and replace dynamic values via for loop

I think this is what you want, List<string> keys = new List<string>() { “name”, “age”, “param3” }; string url = “http://www.test.com/test.aspx?testinfo=&|&;”; Regex reg = new Regex(“&”); int count = url.Count(p => p == ‘&’); for (int i = 0; i < count; i++) { if (i >= keys.Count) break; url = reg.Replace(url, keys[i], 1); } … Read more

[Solved] How can i find all the times between two given dates and time? [closed]

Gee, sometimes its fun to overengineer things. There is an Aggregate function which turns a list into a scalar value – lets create one that goes the other way public static class Extensions { public static IEnumerable<T> Explode<T>(this T value, Func<T,T> next, Func<T,bool> limit) { var n = value; while(!limit(n)) { yield return n; n … Read more

[Solved] How to disable enter alphabet symbols in Combobox C#?

You can use Regex As an example In Combobox_TextChanged event if charcter match remove it private void comboBox1_TextChanged(object sender, EventArgs e) { string rex=comboBox1.Text; Regex regex = new Regex(@”^\d$”); if (regex.IsMatch(compare)) { rex= Regex.Replace(rex, @”(?<=\d),(?=\d)|[.]+(?=,)[A-Z]”, “”); } comboBox1.Text=rex; } This can help you. Regex for numbers only 5 solved How to disable enter alphabet symbols … Read more

[Solved] How can I respond to a keyboard chord and replace the entered alpha key with a special one?

Here’s one way to accomplish this for all TextBoxes on your Form: public partial class Form1 : Form { public Form1() { InitializeComponent(); } protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (this.ActiveControl != null && this.ActiveControl is TextBox) { string replacement = “”; TextBox tb = (TextBox)this.ActiveControl; bool useHTMLCodes = checkBoxUseHTMLCodes.Checked; if … Read more

[Solved] Why is the Windows Forms UI blocked when executing Task with ContinueWith?

Since you already create (and save) your tasks, the easiest fix would be to await them for each iteration of your while loop: while (run) { action2(); foreach (Task t in continutask) await t; } That way, when all pings completed (successful or not) you start the entire process again – without delay. One more … Read more

[Solved] How to get all images from a url to picturebox in c#?

Just create picture box at runtime on form load like this. And you have to only increament x and y value after every cycle private void Form1_Load(object sender, EventArgs e) { int x = 10, y = 10; string[] file = System.IO.Directory.GetFiles(@”C:\Users\Public\Pictures\Sample Pictures\”, “*.jpg”); PictureBox[] pb = new PictureBox[file.Length]; for (int i = 0; i … Read more

[Solved] How to reuse a form ( and change its context when needed) to avoid multiple identical forms? C# [closed]

Why do you need a new form class for each country? The idea of a class is that it holds common behaviours. A form is a class. just instantiate an instance of the class with the data that it needs to display. Create a data class to encapsulate the data that the form shows (like … Read more

[Solved] Trying to show a Windows Form using a DLL that is imported at the runtime in a console application

The problem is that Activator.CreateInstance does not return ExpandObject (dynamic). You should run test() by reflection, like this : foreach (Type type in DLL.GetExportedTypes()) { dynamic c = Activator.CreateInstance(type); MethodInfo methodInfo = type.GetMethod(“test”); methodInfo.Invoke(c , null); } 2 solved Trying to show a Windows Form using a DLL that is imported at the runtime in … Read more

[Solved] Battery Status in winforms

I thing that what you want to do is this: private void BatteryStatus() { System.Management.ManagementClass wmi = new System.Management.ManagementClass(“Win32_Battery”); var allBatteries = wmi.GetInstances(); foreach (var battery in allBatteries) { int estimatedChargeRemaining = Convert.ToInt32(battery[“EstimatedChargeRemaining”]); label13.Text = “Remaining:” + ” ” + estimatedChargeRemaining + ” ” + “%”; } } No need for and if statment, the … Read more