|
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 />
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 />
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.
|
|
|
|
|
John Fisher:
Thanks!!! I will try your code and will
let you know whether it worked.
Much appreciated!!!
New_Phoenix
|
|
|
|
|
Why does this match?
string sSearch = "-- --";
const string sRegEx = "[a-z]*[A-Z]*[0-9]*";
if (Regex.IsMatch(sSearch, sRegEx)) {
}
My understanding is, it should allow any number of characters in the range of a-z, A-Z or any number between 0-9. I guess there is something basic I'm missing out here
/matthias
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
|
|
|
|
|
* matches 0 or more occurences of the previous character or subexpression, while + matches 1 or more.
Try this instead:
const string sRegEx = "[a-z]+[A-Z]+[0-9]+";
|
|
|
|
|
Thanks for your reply!
dratcha wrote:
<* matches 0 or more occurences of the previous character or subexpression, while + matches 1 or more.
Yes, but if I use a + instead of a * doesn't that mean i will definetely need 1 char in the range [a-z], plus one in the range [A-Z] and so forth?
With the expression I've build in my previous post (using *), I thought to provide a subset of characters which should be allowed as input. But the string '-- --' marched right through claiming it was valid. How come? It wasn't listed in any of the subsets!
I just want to understand...
/matthias
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
|
|
|
|
|
|
Hi leppie,
thanks for your reply. I still don't understand why IsMatch is returning true. For my understanding it should return true if a match has been found. My regular Expression states, that allowed characters are a-z, A-Z, 0-9 in any quantity. It doesn't say that '--' is a valid character.
Could you please provide a short snippet that does the following: Check a given string (say, the SearchString) whether all input characters are falling into these categories a-z, A-Z, 0-9. If the SearchString contains one or more invalid characters, such as : or ; or -, the check should fail and an empty string should be returned. If all characters are valid, the snippet should return the complete SearchString as it was originally passed to the method.
I usually don't ask people writing code for me, but I really would like to understand the workings here. Drives me nuts to walk around and make a stupid face...
Thanks in advance!
/matthias
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
|
|
|
|
|
matthias s. wrote:
allowed characters are a-z, A-Z, 0-9 in any quantity
In Regex terms thats is an ambigious description.
Do you mean?
a. any number of a-z followed by, any number of A-Z followed by, any number of 0-9 ([a-z]*[A-Z]*[0-9]* ). This is also note really correct (it can be, but the Regex wil be complex), but you can check the Length property of the returned Match object if its larger than 0.
b. one of more of a-z OR A-Z OR 0-9 ([a-zA-Z0-9]+ or using a character class \w+ that matches any alphabet char or number).
Also you want to check the whole input string, so u will need to add SOL/EOL markers. Eg.
^\w+$
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
if u want enter string not contains any special chars.
It should contain only alpha numeric then use this code
string sSearch = "-- --";const string sRegEx = "[a-zA-Z0-9]";
if (Regex.IsMatch(sSearch, sRegEx)) //if return true
{
// do something funny
}
Naveen Sagar
|
|
|
|
|
|
Hi!
Is it possible to hide columns in the datagrid?
When using the original setup of the datagrid every column is displayed. And if you would like to populate the datagrid with information from a database, it displays the primary key and foreign key columns as well.
Is there a way to hide an arbitrary column in the datagrid, but still being able to reach the value of the it behind the scenes?
Thank you!
|
|
|
|
|
Sounds like you need to look into using the DataView. Research to see if it fits your needs, then ask again if you need more info.
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.
|
|
|
|
|
Yes, check the DataGridTableStyle class. The basic idea is that you create one DataGridTableStyle object, and then add DataGridTextBoxColumn or other column types (check boxes por example) to the table style, only for the columns you want to display (use the MappingName property).
Here's an example, from some code I'm working on right now:
DataGridTableStyle style = new DataGridTableStyle();
style.MappingName = dtZoneCollectors.TableName;
DataGridTextBoxColumn textCol = new DataGridTextBoxColumn();
textCol.MappingName = "column_name";
textCol.HeaderText = "Name as it will appear to the user";
textCol.Width = 200;
textCol.ReadOnly = true;
style.GridColumnStyles.Add(textCol);
gridCollectors.TableStyles.Add(style); It only adds one column, but hopefully you'll get the idea.
Good luck!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Thank you!
|
|
|
|
|
I am very new to C# (using C# express beta 2.0) and need some help.
I started a windows form, added a web browser and specified the URL location.
On that page, I want to select (check box) items that match my list and add to cart. I searched a lot but was not able to find how to do this. Any help is appreciated.
|
|
|
|
|
Hello,
I am new to the field of security. I am looking for a program that implements the "Secure Electronic Transaction" (SET) protocol. Is such a program available?
Thank you very much in advance.
I am also looking for help on Microsoft Security Toolkit. Is it already installed with VS .NET? or must it be separately installed? Any tutors on using it?
Thank you very much for all the help.
|
|
|
|
|
It seems that the ValueMember property of Combobox doesn't accept the data of INT type
I've got a table including two fields(subID: int and subName: nvarchar)
combobox.DisplayMember = "subName"
combobxo.ValueMember = "subID"
when i bind my table to combobox
it always report error message: "Incorrect input string format"
Thanks
|
|
|
|
|
Try this:
YouTable[SubID].ToString().
|
|
|
|
|
I have added this lines as recormended to InitializeComponent()
this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint,true);
What i am doing is reading an array in memory with a reference to locations on an image.
I then draw the source image to a bitmap then clone the needed area(described in the array element) to a second bitmap then draw that to a onto a panel on a form.
The program is a graphical level editor for a 2D tile engine based game and it works fine except when i scroll around the level editor window the image redraw looks horrible even with the double buffering enabled.
Any advice?
Thanks in advance,
James.
|
|
|
|
|
Try it this way:
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
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.
|
|
|
|
|
Try calling the UpdateStyles method afterwards to force the assigned styles to be reapplied to the control.
www.troschuetz.de
|
|
|
|
|
Thanks guys tried both of those and no joy
|
|
|
|
|
I'm building a GUI that has a lot of data to display, and therefore, space is increasingly becoming an issue. I'd like to get round this by making a floatable, collapsable and dockable tab menu. But i'm not sure where to begin.
I'm guessing at the following:
* popup menus are displayed next to a single tab line, and are displayed over the rest of the GUI elements. So, it would make sense for them to be a form in this state, managed by the parent form.
* When floating, they would appear to be a form also, this makes sense going by the previous state.
* When docked, the internal panel to the form is simply returned to the parent form, and the parent form re-arranged as appropriate, using some kind of dock manager.
But these are only guesses, and as I do not have anywhere near enough money to go out and buy control packages, i was hoping to make a (very) simple version myself.
So i'm really just looking for some pointers as to where to start.
Cheers
Cata
|
|
|
|
|
|
Hey!
I need som help on the MemoryStream.
1. Is MemoryStream contaning one ore two streams?
1.2. If the MemoryStream only contains one stream, is it still posible to send data in both directions, or do i need to have two MemoryStreams to do that?
1.3. If the MemoryStream is containgn two streams, how do i know what stream i am reading and writing from?
As you can see, i have some problem to understand Streams, if you got the time to explain, i would appreciate it!
Best Regards
Jimmy
|
|
|
|