|
led mike wrote: If it is not firing then something is not set correctly.
I thought about that for a second then I realized that I didn't have AutoPostBack set to true for the control.
Works fine now Thanks for the heads up!
|
|
|
|
|
I have been working on an application that utilizes the DragDrop Event Handler. To accomplish this, I created a "public" variable named dragPoint which has both X and Y coordinates and made the assignment to that point in the MouseDown() Event handler.
The cursor remembers that clicked point on the control from the MouseDown() Event Handler when the user clicks on the control. However, the DragOver() Event handler does not reconcile that point click from the MouseDown() Event handler properly. Could somebody please provide some insights as I am missing some concept here.
The code is as follows:
private static void _ctrl_DragOver(object sender, DragEventArgs e)
{
try
{
if(DragDropHandler.CanDropHere((Control)sender, e.Data))
{
Control cthis = (Control)sender;
e.Effect = DragDropEffects.Move;
Control ctrl = DragDropHandler.GetControl(e.Data, false, true);
// Here is the code with the problem
Point NewLocation = cthis.PointToClient(new Point(e.X, e.Y));
ctrl.Left = NewLocationX + 2;
ctrl.Top = NewLocation.Y + 2;
// End problem code above
}
else
{
// Error Message
}
}
}
Note: I tried subtracting away the dragPoint.X from the "new Point()"
in the cthis.PointToClient() but that only causes the cursor to change to a circle with a slash through it indicating a mathematical conceptual error somewhere. I also tried to add the dragPoint.X to the ctrl.Left and the ctrl.Top, and while that does work, it causes the cursor to be placed to the left and to the top at a point equal to the point that the control is clicked in the MouseDown() Event. When I tried to subtract the dragPoint.X and dragPoint.Y from the ctrl.Left and ctrl.Top statements, then the cursor changes again to a circle with a slash through it.
What concept have I missed here? Should I be using PointToClient() or PointToScreen() ot something else to get the cursor to drag from the point that the user clicks on the control?
// Alternate code tried
Point NewLocation = cthis.PointToClient(new Point(e.X - dragPoint.X, e.Y - dragPoint.Y));
ctrl.Left = NewLocationX - dragPoint.X;
ctrl.Top = NewLocation.Y - dragPoint.Y;
// End alternate code tried
-- modified at 18:31 Saturday 6th May, 2006
|
|
|
|
|
Try using an offset with respect to the initial position. Modify your alternate code as follows:
<br />
ctrl.Left = ctrl.Left + e.X - dragPoint.X;<br />
ctrl.Top = ctrl.Top + e.Y - dragPoint.Y;<br />
|
|
|
|
|
Is there a program out there that can read tags for .m4a files (itunes formats) and that has source code for c#? I already found one for reading id3 tags on .mp3 files here: http://www.codeproject.com/csharp/ShellID3TagReader.asp, but I have yet to find one that will work on .m4a files.
Thanks!
|
|
|
|
|
|
Should be in the .NET framework install dir. I have 2 versions (in for 1.1 and one for 2.0).
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
i've serched into all my pc but no found.
Where can i downalod it? and where can i found a tutorial to use?
|
|
|
|
|
Susuko wrote: Where can i downalod it?
You could try reinstalling the .NEt framework or VS200x.
Susuko wrote: where can i found a tutorial to use?
Here are a few:/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Hello
I want convert a file into a stream.
I do it like this:
FileInfo fl = new FileInfo(@"C:\test.wav");
Stream sm = fl.Open(FileMode.Open);
But I do not think this is the best way to do it!
Can someone tell me if this is a good way, or maybe tell me a better way of how to do this?
Thanks
QzRz
|
|
|
|
|
This is a good way, but the FileInfo object is not necessary (unless you are using it somewhere else).
Try this:
Stream sm = new FileStream(@"C:\test.wav", FileMode.Open);
Hope this helps,
DigitalKing
|
|
|
|
|
Thanks for the fast reply
I do not need the FileInfo, so the answer you gave me is very good.
Thanks
|
|
|
|
|
What DigitalKing said, but you could also use the using statement to close the stream and release resources correctly. Something like
using (Stream s = ...)
{
}
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
i m making a programe which show the logical drives using string how can represent it in tree view form
majid shahid
|
|
|
|
|
You are looking for the TreeNode[^] class. You can access the nodes in the tree using treeView.Nodes , so to add nodes, just do treeView.Nodes.Add(yourtext) . To add subnodes, get a reference to the TreeNode object using treeView.Nodes[i] and then call Add on its node collection.
Does this answer your question?
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
how can i represent the string in treeview form.
majid shahid
|
|
|
|
|
What the heck are you talking about?
|
|
|
|
|
Hi,
I have a problem with checkbox. Actually i have a form on which there are two grids, two radio buttons and a check box. Basically when i databind the check box and/or radio buttons, the other controls dont work properly. Specially when adding new rows to grids(Which are added by clicking NEW button on the tool bar) the CURRENT row does not get to the new row. And also the only textbox does not become blank when we click NEW. I know there is some problem with Checkbox databinding but i really dont know what that problem is and how to remove that problem. Please tell me if any one know about that...
Regards,
Wasif Ehsan,
Software Engineer.
-- modified at 9:25 Saturday 6th May, 2006
|
|
|
|
|
VS 2005 C# Express, .NET 2.0
The following code causes the Body member of the Webbrowser control to be set to null. Why?
mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2) this.webBrowser1.Document.DomDocument;
doc2.designMode = "On";
I am trying to programmatically select an element (<OPTION>) in a web page listbox (<SELECT>) the way a user would with the left mouse button. So, far I've found nothing that will do this.
|
|
|
|
|
cweeks78681 wrote: I am trying to programmatically select an element (OPTION) in a web page listbox (SELECT) the way a user would with the left mouse button.
What does that have to do with setting designMode to ON?
Would you know how to do that in a javascript running in the HTML page? If not you should learn how to do that first because it is the same thing. The DOM in WebBrowser is the same DHTML DOM you use in javascript.
You want to get a reference to the DHTML listbox element and set it's .selectedIndex property to the desired index.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
> What does that have to do with setting designMode to ON?
It was a shot in the dark. I thought maybe the HTMLDocument was in some kind of read-only state because I have NEVER found a way to modify a page in the web browser. Some kind of exception is always thrown. One said something about an access violation.
|
|
|
|
|
That's what I call it, anyway...
I want to write a class that would know how to act on two different cases:
- A single object of it was created.
- An array of objects of it was created.
The purpose of this is to fire a different event for each of the cases.
Lets take WinSck for example...
If you create a single object, you get the regular arguments.
But create an array, and it automatically generates the same event with an additional index argument.
1. How can I detect from within my class if it's used as an array?
2. How can I, after detection, pass the index of the object, without holding an index/id field inside the class?
Thanks in advance,
Shy.
|
|
|
|
|
Hu?
I don't think you made yourself clear enough to get helpful answers.
When you want to know how many instances of your class have been created, you can increase a static counter in the c'tor of your class, for example.
But your class will never know if it's part of an Array or not, unless you define a separate Collection class to hold elements of your class.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
1. You can't. How the reference to an object is stored is not known to the object.
What you can do is to use a static variable in the class that keeps track on how many objects has been created.
2. You can't. Same reason.
---
b { font-weight: normal; }
|
|
|
|
|
Thank you both for you comments...
I've got an idea, but not sure if it's possible.
I can create two different classes that will inherit thier common stuff.
Each of this classes would call the appropriate event (With/out index).
One of them will use a static field as you both mentioned.
BUT... Question is...
Can I force one class to be used as an array, and not as a single object?
Maybe inheriting both System.Array, and my base class would help?
Thanks,
Shy
Added:
Or maybe I can just implement ICollection...?
-- modified at 11:29 Saturday 6th May, 2006
|
|
|
|
|
I have a custom collection class that is bound to a PropertyGrid object, which functions very well. Part of the collection class is as follows:
public DotCommand[] Attributes
{
get
{
return attributes;
}
set
{
attributes = value;
if (AttributesChanged != null)
AttributesChanged(this, new EventArgs());
}
}
The PropertyGrid shows the Attributes item, with an ellipsis button (...); when I click on the button the Object Collection Editor appears and I can add items (the DotCommand object is very simple, it just contains two string objects, exposed with public get/set properties). When I dismiss the Object Collection Editor with Ok, the setter for the Attributes property above is not hit. If I press the ellipsis again, only the last added item is displayed (the others are gone).
What do I need to do to wire the PropertyGrid and Attributes property together properly? Is it because the Attributes property is an array (DotCommand[] )?
- Dy
|
|
|
|