|
Nick,
Heh heh ... I read all of the documents on drag-and-drop operations with the RichTextbox and how easy it is as well. Unfortunately, if you go into VSS and lookup RichTextBox.DragOver you will see the following message:
This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
As a result there is no way I can wire in my handlers since there are not events exposed.
And that is why I am looking for an alternative.
This signature left intentionally blank
|
|
|
|
|
Would something like this work?
public class RtbDerivitive : RichTextBox
{
public event DragEventHandler DragOver;
protected override void OnDragOver(DragEventArgs drgevent)
{
if (DragOver != null)
DragOver(this, drgevent);
base.OnDragOver(drgevent);
}
}
Judah Himango
|
|
|
|
|
He shouldn't need to subclass the RichTextBox to perform a simple drag and drop operation, see my example below.
- Nick Parker My Blog | My Articles
|
|
|
|
|
theRealCondor wrote:
As a result there is no way I can wire in my handlers since there are not events exposed.
Strange, it does work, I just tested this:
using System;
using System.Drawing;
using System.Windows.Forms;
public class test : System.Windows.Forms.Form
{
RichTextBox rtb;
public test()
{
InitializeComponents();
}
public void InitializeComponents()
{
rtb = new RichTextBox();
rtb.Location = new Point(0, 0);
rtb.Size = new Size(200, 250);
rtb.AllowDrop = true;
rtb.DragEnter += new DragEventHandler(rtbDragEnter);
rtb.DragDrop += new DragEventHandler(rtbDragDrop);
this.Controls.AddRange(new Control[] {rtb});
}
private void rtbDragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
private void rtbDragDrop(object sender, DragEventArgs e)
{
int i;
String s;
i = rtb.SelectionStart;
s = rtb.Text.Substring(i);
rtb.Text = rtb.Text.Substring(0,i);
rtb.Text = rtb.Text +
e.Data.GetData(DataFormats.Text).ToString();
rtb.Text = rtb.Text + s;
}
[STAThread]
public static void Main()
{
Application.Run(new test());
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
I cut and paste the code into a project here and it compiled (and accepted drop) correctly. So I went into my main project ...
I cannot see the drag/drop events in the property grid.
But I can program them by hand.
And the Browse(false) is set on these events!!!!
So they don't show up in Intellisense but they respond once coded.
So they are just removing them from the browser to keep people from using them. Which makes me think there may be a reason. No?
I'll see what happens...
This signature left intentionally blank
|
|
|
|
|
Just because the documentation says you shouldn't use it doesn't mean you can't - just be ready for errors. I've implemented IXmlSerializable on numerous occassions and the .NET Framework SDK says you shouldn't in .NET 1.0 and 1.1. In .NET 2.0 they are releasing the documentation for it, but it really wasn't hard to figure out.
The documentation isn't the thing that you should be looking at anyway. Open ildasm.exe in the .NET Framework SDK Bin directory or use .NET Reflector[^] and take a look at the actual code (the IL instructions or the best-guess decompilation in whatever languages .NET Reflector currently supports or are provided through add-ins). That's the only way to know for sure.
Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
|
|
|
|
|
Heath Stewart wrote:
I've implemented IXmlSerializable on numerous occassions and the .NET Framework SDK says you shouldn't in .NET 1.0 and 1.1.
Hey, I've done that too, mine was because Javier asked me for a way to serialize a Hashtable to XML.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I've been looking at how to change the password of an Active Directory user in a C# application. I've seen many examples of code that create a DirectoryEntry object for the user and then Invoke("setPassword","newPassword"); . While this is useful, I can't help wondering where they are getting this information from. I haven't, yet, been able to find where I get a list of the methods I can "invoke" on a DirectoryEntry of an Active Directory User, or any other Active Directory object.
Perhaps, because I'm new to actually using Active Directory, I'm just looking in the wrong place. And, although I can do the job I need to based on the sample code I've seen, I still want to know how it is actually working.
Would someone be good enough to point me in the right direction?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
|
Thanks, I'll definitely have a look at that in more detail when I get in to work tomorrow morning.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
How are you drawing onto the picture box?
You can easily save the image with custom drawn stuff:
Image img = ...;
Graphics g = Graphics.FromImage(img);
g.DrawString(...)
g.DrawLine(...)
g.Dispose();
now you're image has the stuff you have drawn on it, so you can do:
img.Save(filename);
if you don't want to change the original image you can do:
Image img = ...;
Bitmap bmp = new Bitmap(img.Width, img.Height);
Graphics g = Graphics.FromImage(bmp);
g.DrawImage(img, 0, 0, img.Width, img.Height);
... other drawing stuff
g.Dispose();
bmp.Save(filename);
|
|
|
|
|
I tried that, I keep getting an out of memory exception...
not sure what to do
You Know We Non-Stop
|
|
|
|
|
What file format are you saving it as?
There is a bug that won't let you save it to file png files.
Try using:
img.Save("file.bmp", ImageFormat.Bmp);
|
|
|
|
|
Hi
i am working with ADSI with win 2003 server in c# ... i am trying to make a user the member
of a group named "Administrators" ... my user is in an ou named "test2" ... when i start the
program ... in the end when it should add the user in Admiistrators group it give me this
error
"System.Runtime.InteropServices.COMException(0x8004005): Unspecified error"
my code is as under... it is on a button click.
private void button5_Click(object sender, System.EventArgs e)
{
try
{
DirectoryEntry dom = new DirectoryEntry("LDAP://CN=Builtin,DC=jacal99,DC=com");
DirectoryEntry group = dom.Children.Find("CN=Administrators");
MessageBox.Show("group found");
DirectoryEntry dom2 = new DirectoryEntry("LDAP://OU=test2,DC=jacal99,DC=com");
DirectoryEntry usr = dom2.Children.Find("CN=lucky");
MessageBox.Show("user found");
group.Properties["Member"].Add(new string[] {"lucky"});
group.CommitChanges();
MessageBox.Show("user added ");
}
catch (Exception ex)
{
MessageBox.Show("error coz " + ex);
}
}
ok waiting for the answer ... seea TC bye.
Mazhar Hussain
|
|
|
|
|
Using MessageBox.Show is a poor way of debugging. Insert a breakpoint into your code and step through it. On what line does the exception occur? Even just running your code in the debugger (Visual Studio .NET or cordbg.exe) with the necessary symbols (built by default for the Debug project settings) will tell you. That information will be helpful to help you solve your problem.
Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
|
|
|
|
|
I pull an image onto the picturebox control as its 'image' property. Then I draw some arrows on the picturebox (not into the image itself).
How do I save the image + the arrows I draw onto the image, out to disk?
I have tried using the BitBlt function but it seems that BitBlt always takes data from the screen-buffer as opposed to the picturebox itself. This is an issue for me because some of the picture I need is underneath scroll-bars...
Anyone have any ideas?
You Know We Non-Stop
|
|
|
|
|
Sorry, this would probably be better asked in the .NET Framework forum, but I get better responses in this one. My C# application, compiled with VS.NET 2002 Pro, which uses the .NET Framework version 1.0.xxx, runs perfectly on a machine with the .NET Framework version 1.0.xxx. However, when this program is required to run under a more recent version of the .NET Framework, I notice different functionality in certain areas of the application. The code simply cannot be anymore straightforward, it works on the same .NET version I compiled it under. My question is, if I compile this same code with VS.NET 2003, or even 2005, will the application run PROPERLY when it is running under 1.1.xxx or newer? Could there be another cause...like I said before, it runs perfect under the older version of the .NET Framework, but not so much under more recent versions. I'd appreciate the help on this...
|
|
|
|
|
.NET versions can be installed side-by-side; if you want to use the 1.0.xxx version, specify this in the configuration file for your assembly. Search MSDN if you need an example.
.NET 1.1 breaks a few 1.0 things, mostly security and remoting stuff though. If your code is as simple as you say, post some code that works differently on 1.1.
Judah Himango
|
|
|
|
|
Extending on what Judah said, look-up the <supportedRuntime> configuration element. It's only supported in .NET 1.1 and newer, since anything targeting the 1.0 framework doesn't really have a choice for backward compatibility.
There's also a lot of information about side-by-side execution in the "Programming Topics" section in the .NET Framework SDK I encourage you to read. I'd give you a link, but unfortunately I'm having connection problems to certain servers. Go figure. It's not hard finding anyway.
Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
|
|
|
|
|
I am trying to call an ActiveX DLL written in VB6 from my C# app.
The function call has a single parameter that is declared optional.
How do I call it from C#?
The VB function is:
Public Function GetTasks(Optional ByVal lngUserCode As Long) As ADODB.Recordset
|
|
|
|
|
I want to call the function without a parameter so the entire recordset is returned.
|
|
|
|
|
|
Hi All,
How I convert a text file (delimiters are blank spaces) in xml file.
luciano_rib@yahoo.com.br
|
|
|
|
|
lklkjlk wrote:
How I convert a text file (delimiters are blank spaces) in xml file.
just like you need to. :p
top secret xacc-ide 0.0.1
|
|
|
|
|
The easiest way is probably to decide on a schema (format of the xml) and then iterate through all of your text file and transform it on the fly into a string that has your schema. You can then do what you want with the XML.
store your internet favourites online - www.my-faves.co.uk
|
|
|
|