Click here to Skip to main content
15,889,034 members
Home / Discussions / C#
   

C#

 
GeneralRe: Can i add a background image to the Windows datagrid? Pin
RajeshGuptha19-Apr-05 19:14
RajeshGuptha19-Apr-05 19:14 
GeneralRe: Can i add a background image to the Windows datagrid? Pin
Jim Matthews20-Apr-05 3:14
Jim Matthews20-Apr-05 3:14 
GeneralRe: Can i add a background image to the Windows datagrid? Pin
RajeshGuptha20-Apr-05 7:20
RajeshGuptha20-Apr-05 7:20 
GeneralTray Icons Pin
CStiefeling19-Apr-05 8:09
CStiefeling19-Apr-05 8:09 
GeneralRe: Tray Icons Pin
leppie19-Apr-05 19:11
leppie19-Apr-05 19:11 
QuestionDb2 connection?? Pin
trk_wakil19-Apr-05 7:38
trk_wakil19-Apr-05 7:38 
GeneralDragOver assistance needed... Pin
new_phoenix19-Apr-05 7:27
new_phoenix19-Apr-05 7:27 
GeneralRe: DragOver assistance needed... Pin
John Fisher19-Apr-05 8:27
John Fisher19-Apr-05 8:27 
If all you want is to drag from the spot you "grabbed", then you don't need to use the Rectangles. You can to do that with something like the following. (Note that I didn't actually test this code...)

It works by turning your "dragPoint" variable into an offset from the top-left corner of the control being dragged. Then, every mouse move can subtract that offset from the current mouse position to get the control's desired position.

<br />
private void MouseDown(object sender, MouseDownEventArgs e)<br />
{<br />
// assign the dragPoint in MouseDown<br />
dragPoint.X = e.X;<br />
dragPoint.Y = e.Y;<br />
dragPoint = PointToClient(dragPoint);<br />
dragPoint.X -= ctrl.X;<br />
dragPoint.Y -= ctrl.Y;<br />
}<br />
<br />
private void DragOver(object sender, DragEventArgs e)<br />
{ <br />
// cthis is the form that the control is dragged over and ctrl is the control dragged<br />
System.Drawing.Point NewLocation = cthis.PointToClient(new System.Drawing.Point(e.X, e.Y));<br />
ctrl.Left = NewLocation.X - dragPoint.X;<br />
ctrl.Top = NewLocation.Y - dragPoint.Y;<br />
}<br />


John

"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.

GeneralRe: DragOver assistance needed... Pin
new_phoenix19-Apr-05 8:38
new_phoenix19-Apr-05 8:38 
GeneralRegex: Very basic question Pin
matthias s.19-Apr-05 5:42
matthias s.19-Apr-05 5:42 
GeneralRe: Regex: Very basic question Pin
dratcha19-Apr-05 6:52
dratcha19-Apr-05 6:52 
GeneralRe: Regex: Very basic question Pin
matthias s.19-Apr-05 12:23
matthias s.19-Apr-05 12:23 
GeneralRe: Regex: Very basic question Pin
leppie19-Apr-05 19:18
leppie19-Apr-05 19:18 
GeneralRe: Regex: Very basic question Pin
matthias s.20-Apr-05 0:16
matthias s.20-Apr-05 0:16 
GeneralRe: Regex: Very basic question Pin
leppie20-Apr-05 3:58
leppie20-Apr-05 3:58 
GeneralRe: Regex: Very basic question Pin
Member 163675520-Apr-05 23:39
Member 163675520-Apr-05 23:39 
GeneralRe: Regex: Very basic question Pin
leppie19-Apr-05 19:21
leppie19-Apr-05 19:21 
GeneralDatagrid formatting Pin
esjq19-Apr-05 4:55
esjq19-Apr-05 4:55 
GeneralRe: Datagrid formatting Pin
John Fisher19-Apr-05 8:14
John Fisher19-Apr-05 8:14 
GeneralRe: Datagrid formatting Pin
Luis Alonso Ramos19-Apr-05 9:17
Luis Alonso Ramos19-Apr-05 9:17 
GeneralRe: Datagrid formatting Pin
esjq19-Apr-05 19:58
esjq19-Apr-05 19:58 
QuestionHow to select a check box and add to cart in C# Pin
userid_userid19-Apr-05 3:43
userid_userid19-Apr-05 3:43 
Question&quot;Secure Electronic Transaction&quot; in C#? Pin
msdawy19-Apr-05 3:30
msdawy19-Apr-05 3:30 
GeneralComboBox problem Pin
vuthaianh19-Apr-05 2:44
vuthaianh19-Apr-05 2:44 
GeneralRe: ComboBox problem Pin
MoustafaS19-Apr-05 4:25
MoustafaS19-Apr-05 4:25 

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.