Relative Content

Tag Archive for c#winforms

Form with transparent element

In CSharp, on Windows 11, I have a form with a solid background and a transparent PictureBox. The form loads and PictureBox is actually transparent, but when I move the mouse over the transparent area the mouse handling gets sent to objects behind the form.

How can the button color be changed using the method

namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void Chose() { this.BackColor = Color.White; } private void F03_Click(object sender, EventArgs e) { Chose(); } } } I have a lot of buttons and when you click on any one it should change color. preferably through this (it […]

How to delete drawn points from image file?

I’m reading list of points from a json file and then draw the points on a file and then display the file with the drawn points. the problem is that if before loading i wad drawing points they will stay when loading. i need to clear the image file before drawing the points form the loading json. i’m not using paint event but Graphics for drawing on the image file.

How do I get my button to work on the first click?

In Winforms I have 72 buttons with images that are supposed toggle back and forth between different images when clicked, but I can’t find why the first click doesn’t make them toggle, all clicks after the first click seem to work as expected.

Why when drawing points on picturebox the last point gets deleted?

private void pictureBoxPoints_MouseDown(object sender, MouseEventArgs e) { if (pictureBoxPoints.Image != null) { pointCoordinates.X = e.X; pointCoordinates.Y = e.Y; // Convert point coordinates from pictureBoxPoints to original frame coordinates double xFactor = (double)pictureBoxPoints.Image.Width / pictureBoxPoints.Width; double yFactor = (double)pictureBoxPoints.Image.Height / pictureBoxPoints.Height; double xOffset = _convertedRectangle.X; double yOffset = _convertedRectangle.Y; int imageX = (int)(pointCoordinates.X * xFactor) + […]

Why when drawing points on picturebox the last point is get deleted?

private void pictureBoxPoints_MouseDown(object sender, MouseEventArgs e) { if (pictureBoxPoints.Image != null) { pointCoordinates.X = e.X; pointCoordinates.Y = e.Y; // Convert point coordinates from pictureBoxPoints to original frame coordinates double xFactor = (double)pictureBoxPoints.Image.Width / pictureBoxPoints.Width; double yFactor = (double)pictureBoxPoints.Image.Height / pictureBoxPoints.Height; double xOffset = _convertedRectangle.X; double yOffset = _convertedRectangle.Y; int imageX = (int)(pointCoordinates.X * xFactor) + […]