[Solved] C# Use ‘this’ Keyword in a class [closed]

I am not sure, you can try passing the form reference into the method(if that is what you mean). class MyMenu { public static void AddLine(Form f) { ShapeContainer canvas = new ShapeContainer(); LineShape theLine = new LineShape(); canvas.Parent = f; theLine.Parent = canvas; theLine.BorderColor = SystemColors.ControlDarkDark; theLine.StartPoint = new System.Drawing.Point(-3, 154); theLine.EndPoint = new … Read more

[Solved] Booking System Using C# winform [closed]

You’ll need to establish a connection to your database using a SQLConnection object or the appropriate class depending on your database. For instance: bool isReserved; using (SqlConnection connection = new SqlConnection(connectionString) using (SqlCommand command = new SqlCommand(“SELECT isReserved FROM YourTable WHERE BookingId = 1”, connection)) { connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) … Read more

[Solved] How do I calculate values from multiple textboxes and display in seperate box? [closed]

You can use both a RichTextBox and normal TextBox for this. To ensure that it is read-only, in the designer page do the following; Select the TextBox > Scroll under properties window > Behavior Section > Read-Only property Setting this property to true will make the TextBox non-editable by the user. After you have the … Read more

[Solved] How to make a picturebox dragable?

Yes, it is. Assume a Picturebox named “pbxBigCat” (load it with a pPicture …) Add this lines to your form: public const int WM_NCLBUTTONDOWN = 0xA1; public const int HT_CAPTION = 0x2; [DllImportAttribute(“user32.dll”)] public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); [DllImportAttribute(“user32.dll”)] public static extern bool ReleaseCapture(); And then write an … Read more

[Solved] Dynamic textbox validation [closed]

Assuming cmbRateChart.SelectedValue contains qty value with respect to RangeChart. private void textBox_Validating(object sender, CancelEventArgs e) { bool cancel = false; int number = -1; if (int.TryParse(this.textBox.Text, out number)) { var validRange = Convert.ToInt32(cmbRateChart.SelectedValue) * 6; if (number <= validRange) cancel = false; //passed validation. else cancel = true; //failed validation, number is not in valid … Read more

[Solved] Awaited method call doesnt appear to complete [closed]

The problem is you have two separate tasks running that call ShowProgressText. Task.Run() is not something you normally use unless you are interfacing with code that does not use the C# async/await pattern. So perhaps LoadRapport could be like this: bool IsCompleted; string LogText; private async Task LoadRapport() { LogText = “Disable Replication”; IsCompleted = … Read more

[Solved] Change style of datetimepicker in windows form [closed]

Syncfusion DateTimePickerAdv supports creating rounded corner DateTimePicker. Here is an example. Screenshot You need Syncfusion Essential Studio to be installed for the sample to work. The entire product is available in this link. Note: I work for Syncfusion. 0 solved Change style of datetimepicker in windows form [closed]

[Solved] class that gets a value from database [closed]

public static class myMethods { public static string getName(){ string name = “”; ConnectionStringSettings myConnectionString = ConfigurationManager.ConnectionStrings[“LibrarySystem.Properties.Settings.LibraryConnectionString”]; using (SqlConnection myDatabaseConnection = new SqlConnection(myConnectionString.ConnectionString)) { myDatabaseConnection.Open(); using (SqlCommand mySqlCommand = new SqlCommand(“select Top 1 * from Setting Order By SettingID Desc”, myDatabaseConnection)) using (SqlDataReader sqlreader = mySqlCommand.ExecuteReader()) { if (sqlreader.Read()) { name = sqlreader[“Name”].ToString(); } } … Read more