C sharp draw table

Posted on 2005-04-24
Last Modified: 2008-03-17
 i had drawed a table i want to fill a color in some cells in this table by clicking with the mouse pointer, but the problem i want to be attached to the mouse pointer a square that when i click on the mouse button all the cells under this square will be filled by this color, i tried to do this but in my program where the square was going over the table it was erasing these places in the table.

how do i let the sqaure not to erase places on the table where it go over the table (it erase all the line between the coloumn & rows an the data in the cells)

thank you alot
Question by:madmare
    LVL 14

    Expert Comment

    Could you paste the code you are using? WE can't really help you with this if we don't know what kind of structure you use to draw the table.

    Author Comment

    private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
                      Graphics g = CreateGraphics();
                      Pen PnDises = new Pen( Color.Black, 1 );
                      g.DrawRectangle(PnDises, e.X,e.Y,50,50);
                      panel1.BackColor = Color.Transparent;
                      panel1.Left = Cursor.Position.X;
                      panel1.Top = Cursor.Position.Y;


    in each time i move the mouse it draw a square but i want this square to move with the muse pointer
    LVL 14

    Accepted Solution

    Your problem sounds very similair to

    That link might help you out.
    LVL 14

    Expert Comment

    Correction, it is the same question from the same person.
    LVL 5

    Expert Comment

    How are you doing the drawing? Drawing the table in onpaint event? or just onload?  how are you drawing the item under the mouse cursor, via mousemove event?  Are you doing any invalidation of the drawing space?  Do you have autoredraw set to true for the form properties?

    Are you maybe trying to change the color only behind lines you have drawn on the form? if thats the case you need to redraw the lines after you draw the square.  Draw your table in the onpaint event perhaps.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    This article will show, step by step, how to integrate R code into a R Sweave document
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now