[Solved] Sharing one MenuStrip between multiple Forms and “open, save, save as” each form separately

Ok no problem I’ve a Main form and call multiple panel (PanelSlider) with 1 MenuStrip with UserControl : public Form1() { InitializeComponent(); PanelSlider.Controls.Add(new Home()); PanelSlider.Controls.Add(new Tools()); etc… } Active Panel with button private void HomeBtn_Click(object sender, EventArgs e) { PanelSlider.Controls.Find(“Home”, false)[0].BringToFront(); } So to switch the multiple panel I declared a menustrip and for example: … Read more

[Solved] Accessing controls from different forms

Looking at the original code, there are two potential reasons for the NullReferenceException you are getting. First, tb is not defined in the code you provide so I am not sure what that is. Secondly, TextBox textbox = form.Controls[“textboxMain”] as TextBox can return null if the control is not found or is not a TextBox. … Read more

[Solved] How to create PictureBoxes with shapes based on a Picture

My solution to this is a new class: class ShapedPictureBox : PictureBox { public ShapedPictureBox() { } public Color transparentColor = Color.White; public void updateShape() { if(this.Image = null) return; Bitmap bitmap = new Bitmap(this.Image); System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath(); for(int x = 0; x < this.Image.Width; x++) for(int y = 0; y < this.Image.Height; … Read more

[Solved] Thread error in C# Windows Form

You get the Cross-thread error when you try to update a UI element from any thread it was not created on. Controls in Windows Forms are bound to a specific thread and are not thread safe. Therefore, if you are calling a control’s method from a different thread, you must use one of the control’s … Read more

[Solved] How to draw a line from two points? [closed]

By using Graphics.DrawLine, for example: public void DrawLinePoint(PaintEventArgs e) { // Create pen. Pen blackPen = new Pen(Color.Black, 3); // Create points that define line. Point point1 = new Point(100, 100); Point point2 = new Point(500, 100); // Draw line to screen. e.Graphics.DrawLine(blackPen, point1, point2); } See MSDN for more info: https://msdn.microsoft.com/en-us/library/f956fzw1(v=vs.110).aspx solved How to … Read more

[Solved] I want to save user data on client’s machine for c# app [closed]

I would use App.config and access the settings using the ConfigurationManager.AppSettings class. App.Config <?xml version=”1.0″ encoding=”utf-8″ ?> <configuration> <startup> <supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.5″ /> </startup> <appSettings> <add key=”Setting1″ value=”true”/> <add key=”Setting2″ value=”value”/> </appSettings> </configuration> Access settings from your application with the following bool setting1 = Convert.ToBolean(ConfigurationManager.AppSettings[“Setting1”]); string setting2 = ConfigurationManager.AppSettings[“Setting2”]; To update settings create a static … Read more

[Solved] Quantity tracking in the database

In your CheckQuantity() method, you are: Only querying items that have the same quantity of the first ProductInfo that you’re constructing. Displaying the quantity from that single ProductInfo instead of the value you are querying from the database. Instead, this should work better: public static void CheckQuantity(CustomToolTip _customToolTip, IWin32Window _window, int _x, int _y, int … Read more

[Solved] C#, Winform: How to pass information from one form to another [duplicate]

You have to find the form and call the method, e.g. using System.Linq; … Application.OpenForms .OfType<Form1>() // Among the all opened forms of Form1 type .LastOrDefault() // Take the last one (or null if there’s no such form) ?.AfterConnect(); // And call AfterConnect() on it (if the form has been found) 2 solved C#, Winform: … Read more

[Solved] Copying local file to network shared drive issues

Ok, let’s work on this code a little. First let’s simplify building the paths. We have a network path and a local path. According to your current code the network path is built with a few variables comboBox1, comboBox2, and Environment.UserName, so let’s do it a little different: var networkPath = Path.Combine(@”\\network”, comboBox1.SelectedItem as string, … Read more

[Solved] Show folders/files in TreeView ( VB.NET 2008 )

Please search first before ask again and again This ‘Don’t forget to import this Imports System.IO ‘Declare these Private Enum ItemType Drive Folder File End Enum Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For Each drive As DriveInfo In DriveInfo.GetDrives Dim node As TreeNode = _ file_view_tree.Nodes.Add(drive.Name) node.Tag = ItemType.Drive … Read more