Hi,
I don't know C# very well, so I did^n't understand where the problem is. Program works without errors. But it doesn't do what I want, when I click on panel1 , not draws rectangle.

Maybe, you can realise something wrong in the code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace bezier_rotation
{
    public partial class Form1 : Form
    {
        private List<double> ptList = new List<double>();
        private BezierCurve bc = new BezierCurve();

        OpenGLView ogl;
        public Form1()
        {
            InitializeComponent();
            ogl = new OpenGLView();
            ogl.Parent = panel1;
            ogl.Dock = DockStyle.Fill;
            ogl.Refresh();

        }
        Pen px = new Pen(Brushes.Red);
        Pen newpx = new Pen(Brushes.Magenta);
        Graphics g;

        private void Form1_Load_1(object sender, EventArgs e)
        {
            g = Graphics.FromHwnd(panel1.Handle);

        }
        

        
        private void trackX_Scroll(object sender, EventArgs e)
        {
            ogl.setAngleX(trackX.Value);
            lblX.Text = ogl.getAngleX().ToString();
            ogl.Refresh();
        }

        private void trackY_Scroll(object sender, EventArgs e)
        {
            ogl.setAngleY(trackY.Value);
            lblY.Text = ogl.getAngleY().ToString();
            ogl.Refresh();

        }

        private void trackZ_Scroll(object sender, EventArgs e)
        {
            ogl.setAngleZ(trackZ.Value);
            lblZ.Text = ogl.getAngleZ().ToString();
            ogl.Refresh();
            
        }

        private void panel1_MouseClick_1(object sender, MouseEventArgs e)
        {
            //MessageBox.Show("2VELÄ°");

            ptList.Add(e.X);
            ptList.Add(e.Y);

            g.DrawRectangle(px, new Rectangle(e.X, e.Y, 1, 1));

        }

        
     

    }
}

Hi, tuba-zenyep, welcome on the DaniWeb site.

Mostly you cannot use a Graphics object yourself, you must use the one that is given to you. (I read that somewhere...)
Don't know what your exact intensions are but this will work:

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public int x = 0;
        public int y = 0;

        private void panel1_Paint(object sender, PaintEventArgs e)
        {       
            Pen px = new Pen(Brushes.Red);
            Graphics g = e.Graphics;
            g.DrawRectangle(px, new Rectangle(x, y, 1, 1));
            g.Dispose();
        }

        private void panel1_MouseClick(object sender, MouseEventArgs e)
        {
            //MessageBox.Show("2VELÄ°");             
            //ptList.Add(e.X);            
            //ptList.Add(e.Y);  
            x = e.X;
            y = e.Y;
            Refresh();
        }
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.