Click here to Skip to main content
15,892,059 members
Home / Discussions / C#
   

C#

 
AnswerRe: Unable to create a 2-Dimensional Array for Database Records............... Pin
led mike14-Jul-08 10:43
led mike14-Jul-08 10:43 
GeneralRe: Unable to create a 2-Dimensional Array for Database Records............... Pin
Reality Strikes14-Jul-08 10:56
Reality Strikes14-Jul-08 10:56 
GeneralRe: Unable to create a 2-Dimensional Array for Database Records............... Pin
Reality Strikes14-Jul-08 10:59
Reality Strikes14-Jul-08 10:59 
GeneralRe: Unable to create a 2-Dimensional Array for Database Records............... Pin
led mike14-Jul-08 11:09
led mike14-Jul-08 11:09 
GeneralRe: Unable to create a 2-Dimensional Array for Database Records............... Pin
Reality Strikes15-Jul-08 3:20
Reality Strikes15-Jul-08 3:20 
GeneralRe: Unable to create a 2-Dimensional Array for Database Records............... Pin
led mike15-Jul-08 5:36
led mike15-Jul-08 5:36 
QuestionDragable rectangles Pin
Casper Hansen14-Jul-08 9:22
Casper Hansen14-Jul-08 9:22 
AnswerRe: Dragable rectangles Pin
C1AllenS14-Jul-08 9:50
C1AllenS14-Jul-08 9:50 
Hello,

There is no other way apart from this to draw rectangles. However, the only problem was the
calculation part which was working only when you draw from lefttop to right bottom. However,
while doing vice versa, the height and width was getting negative values.

Try this piece of code in MouseUp event()

private void Form1_MouseUp(object sender, MouseEventArgs mouseEv)
{

    textBox2.Text = Convert.ToString(mouseEv.Location);

    Graphics graphics = this.CreateGraphics();
    Rectangle rectangle;

    if (mouseEv.Y > mouseDownY)
    {
        height = mouseEv.Y - mouseDownY;
    }
    else
        height =  mouseDownY - mouseEv.Y;

    if (mouseEv.X < mouseDownX)
    {
        width = mouseDownX - mouseEv.X;

        rectangle = new Rectangle(mouseEv.X, mouseEv.Y, width, height);
    }
    else
    {
        width = mouseEv.X - mouseDownX;
        rectangle = new Rectangle(mouseDownX, mouseDownY, width, height);
    }

    graphics.DrawRectangle(Pens.Red, rectangle);

}


I believe this should resolve your issue.

Regards,

Allen

Allen Smith


ComponentOne LLC
www.componentone.com

GeneralRe: Dragable rectangles Pin
Luc Pattyn14-Jul-08 10:14
sitebuilderLuc Pattyn14-Jul-08 10:14 
AnswerRe: Dragable rectangles Pin
Casper Hansen15-Jul-08 2:58
Casper Hansen15-Jul-08 2:58 
QuestionHelp needed Pin
SHINOJK14-Jul-08 8:23
SHINOJK14-Jul-08 8:23 
QuestionSame Random Numbers Pin
humayunlalzad14-Jul-08 5:27
humayunlalzad14-Jul-08 5:27 
AnswerRe: Same Random Numbers Pin
DaveyM6914-Jul-08 5:34
professionalDaveyM6914-Jul-08 5:34 
GeneralRe: Same Random Numbers Pin
humayunlalzad14-Jul-08 5:36
humayunlalzad14-Jul-08 5:36 
GeneralRe: Same Random Numbers Pin
leppie14-Jul-08 5:38
leppie14-Jul-08 5:38 
GeneralRe: Same Random Numbers Pin
humayunlalzad14-Jul-08 5:52
humayunlalzad14-Jul-08 5:52 
GeneralRe: Same Random Numbers Pin
leppie14-Jul-08 5:54
leppie14-Jul-08 5:54 
GeneralRe: Same Random Numbers Pin
humayunlalzad14-Jul-08 5:57
humayunlalzad14-Jul-08 5:57 
GeneralRe: Same Random Numbers Pin
DaveyM6914-Jul-08 6:07
professionalDaveyM6914-Jul-08 6:07 
GeneralRe: Same Random Numbers Pin
humayunlalzad14-Jul-08 6:17
humayunlalzad14-Jul-08 6:17 
GeneralRe: Same Random Numbers Pin
Colin Angus Mackay14-Jul-08 11:48
Colin Angus Mackay14-Jul-08 11:48 
GeneralRe: Same Random Numbers Pin
humayunlalzad14-Jul-08 18:51
humayunlalzad14-Jul-08 18:51 
GeneralRe: Same Random Numbers Pin
humayunlalzad14-Jul-08 6:53
humayunlalzad14-Jul-08 6:53 
GeneralRe: Same Random Numbers Pin
leppie14-Jul-08 6:55
leppie14-Jul-08 6:55 
GeneralRe: Same Random Numbers Pin
Colin Angus Mackay14-Jul-08 11:49
Colin Angus Mackay14-Jul-08 11:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.