|
What does that have to do with drag and drop? As far as drag and drop goes, you pack the actual object so you don't need to worry about the ID because you have the object itself.
My code was an example and wasn't a full solution. You need to read the .NET Framework SDK documentation and understand what the code is doing and make it work for you. If there was syntactic errors it's because I posted it as an example and don't compile everything I post. That would take forever and you - as the developer - need to understand the code. I'm not just giving out solutions.
The concept is sound and I've used it plenty and provided the example to others in this forum over the past couple years and it's worked. That's just how drag and drop works. .NET makes it easy for you, but unfortunately in doing so it is rather limited (doesn't allow you to specify STGMEDIUM s like with OLE automation).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
The problem is: The user makes controls(by clicking a menu item) from the same tipe(class MyButton : Button) to the clipboard. I've got it! But if I
want to make MyButtons able to move by the mouse(drag-drop) I need to discriminate the MyButton controls on the clipboard to know which MyButton control was clicked or moved!
|
|
|
|
|
No you don't. You use the Type only as the clipboard format (if you don't understand what a clipboard format is, then you really should read about native Drag and Drop in the Shell documentation in the Platform SDK), but the object itself (instances are unique) is packed into the clipboard. Whatever control you click on, be it a Button or MyButton or a different MyButton (and one instance of a control can't be used in multiple places at once because Windows Forms encapsulates the Windows APIs and Common Controls, which wouldn't allow that), are all different instances.
If you're creating controls from a menu, then you simply use the Type passed to Activator.CreateInstance (there's other ways using reflection yourself) to create an instance. Then when a user drags it, they are dragging yet another unique instance of your control. You do not need to distinguish it from another control because the instance is already unique.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Would u show me some code how to use Activator.CreateInstance ?
|
|
|
|
|
|
Where I can found a free C# Outlook-style mini calendar?
Im working in a project of recuuring patterns and I woul like to add some features.
I have seen calendars made in C++ but I dont know nothing this language.
Thank you!
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
Either search this site using the text box below the logo on every page, or use a search engine like google[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank you, i do that first than post it
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
|
Yes, but not in the outlook style.
I found DatePicker control by Lutz Roeder and its have a outlook style calendar in C#. Im trying to get the calendar control, but it no has some properties than I need, like bolded dates and show multiple mode.
But it seems like theres not already the control Im looking for so I need to code it - if I can .
Thank you.
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
What do you mean when you say outlook style?
"Catalonia is not Spain"
|
|
|
|
|
Hi friends...
a .net application when compiled just work in my system and if i want run it on a system that is not installed .net framework on it, i cant and i see an error... how i can compile my application for all systems...???
also i want a reference for GDI+ and graphics in C# , and Work with math functions in C#
|
|
|
|
|
You cannot compile C# to native Win32, the .NET framework is required.
|
|
|
|
|
There's got to be a way you can include a "mini" MSIL interpreter and package the right DLLs with a project... But I can't remember how to do that right now. Hopefully someone else can.
vir·tu·al re·al·i·ty
n. Abbr. VR
A computer simulation of a real or imaginary universe in which Microsoft APIs are thoroughly documented and behave in an entirely logical manner.
|
|
|
|
|
That's BAD! Not only is it not servicable (so that updates to the .NET Framework absolutely WILL NOT apply to your hack) you destroy the very nature of the Framework. If you do something like this (and there is a product that does this) you are responsible for updating your application every time a service pack or generate update is required. It will not - and cannot - be updated automatically by Windows Update or any other method that will update the .NET Framework. This is true for the other platforms I mentioned below.
Applications that target the .NET Framework require the .NET Framework, just like Java applications require a JVM and, more than likely, the JRE (like the .NET BCL), VB6 (and below) applications require the VB Runtime (msvbvm60.dll), and most C/C++ applications require at a minimum the standard C runtime.
In every case, if you import or otherwise use functionality defined elsewhere you require that component. The .NET Framework isn't just a class library - it's a complete runtime with unmanaged components to make the runtime possible (just like a JVM or the VBVM, etc.).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I didn't think the OP was working on an "enterprise solution" or anything that's going to need constant servicing. Maybe his other machine, or his friend has Windows 95 and doesn't want to install the framework because they don't have the space? I understand completely that .NET comprises an entire framework, but I see that the OP could have gotten the wrong idea from my suggestion. It's good that you clarified.
vir·tu·al re·al·i·ty
n. Abbr. VR
A computer simulation of a real or imaginary universe in which Microsoft APIs are thoroughly documented and behave in an entirely logical manner.
|
|
|
|
|
Every time a security patch comes out you should install it. Since it can't and will not install over the hack (it's not even detectable; you broke it) you're still vulnerable. So you, as the developer, would have to re-link all your assemblies with the BCL assemblies and redeploy when important security updates are released. It's not servicable like the .NET Framework would be.
Besides, 1) Win95 doesn't support the .NET Framework, and 2) it's only about 25 MB installed. If someone doesn't have that much space left, not being able to run a particular application should be the last of their worries.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I created a column subclassed from DataGridBoolColumn that has clickable checkboxes. However, if you click the datagrid header for this column it's sorting on the boolean columns original values I think. How can I force the column to sort based on the set/unset value of the checkbox at the moment?
thanks,
Deanna
|
|
|
|
|
Hi all!
For my vs .net 2003 add-in I need a possibility to show hints (-> ToolTip Component?) on words in the VS text-editor. Unfortunately the ToolTip Component can only be applied to controls (the DTE (application) -object does not have any class that is derived from control...
Better than this would be a possibility to implement ms-word-comments in vs .net but i dont think that this is possible, even if i would save the comment-string on my own.
Perhapts anyone can help.
ps: please excuse my bad english
|
|
|
|
|
That's because you're not programming against a .NET application. The EnvDTE assembly is a COM interop assembly (RCW) that allows managed code to marshal calls to native COM components. Of course you won't find anything derived from the System.Windows.Forms.Control class.
You have to use native tool tips, which are documented in the Platform SDK at http://msdn.microsoft.com/library[^]. Specifically, read ToolTip Controls[^].
You might also search MSDN[^] for helpful articles. There have been quite a few covering VS.NET Add-ins and one might just discuss what you need. More often than not, these articles - like here on CodeProject - are accompanied with sample source code.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks a lot. This is exactly the information i needed.
|
|
|
|
|
Hello,
I am developing a library system. I have 2 tables, book and student. The relationship is 1 student can have many books. I am having updating the book table when the student returns the book, the studentID (foreign key) will be cleared from the book table. I think this is the problem l am having. My code is listed below with the error description.
try<br />
{<br />
cnnReturnBook.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\IBS Library System\LibrarySystem.mdb;Persist Security Info=False";<br />
<br />
OleDbCommand cmdReturnBook = cnnReturnBook.CreateCommand();<br />
cmdReturnBook.CommandText = @"SELECT * FROM BOOK<br />
WHERE RefNumber = '" + txtBookRef.Text + "' ";<br />
<br />
OleDbDataAdapter daReturnBook = new OleDbDataAdapter(cmdReturnBook);<br />
OleDbCommandBuilder cbReturnBook = new OleDbCommandBuilder(daReturnBook);<br />
<br />
if ( daReturnBook.Fill(dtReturnBook) == 1 )
{<br />
txtDateOut.Text = "";<br />
txtDateDue.Text = "";<br />
txtStatus.Text = "Available";
txtIDNumber.Text = "";
txtName.Text = "";<br />
txtSurname.Text = "";<br />
<br />
dtReturnBook.Rows[0]["Status"] = txtStatus.Text;<br />
dtReturnBook.Rows[0]["DateOut"] = txtDateOut.Text;<br />
dtReturnBook.Rows[0]["Remarks"] = txtRemarks.Text;<br />
dtReturnBook.Rows[0]["StudentID"] = txtIDNumber.Text;<br />
dtReturnBook.Rows[0]["DateDue"] = txtDateDue.Text;<br />
<br />
daReturnBook.Update(dtReturnBook);
}<br />
}<br />
catch ( OleDbException ex )<br />
{<br />
MessageBox.Show(ex.ToString(),"Exeception has occurred",MessageBoxButtons.OK,MessageBoxIcon.Warning);<br />
}<br />
catch ( Exception ex )<br />
{<br />
MessageBox.Show(ex.ToString(),"Exeception has occurred",MessageBoxButtons.OK, MessageBoxIcon.Warning);<br />
}<br />
finally <br />
{<br />
cnnReturnBook.Dispose();<br />
}<br />
}
Error description
System.Data.OleDb.OleDbException: You cannot add or change a record because a related record is required in table 'Student'.
At System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
At System.Data.Common.DbDataAdapter.Update(DataTable dataTable)
Thanks in advance,
Steve
|
|
|
|
|
I think that the problem is that you've entered the id of a student that doesn't exist in the Database. Either enter a corresponding student into the database or remove the constraint that there must be a student actually responsible for the loan.
|
|
|
|
|
This should really be posted in the ADO.NET forum[^], but I'll try an answer it anyway.
Without knowing more about your data model, I'm guessing that you have no student whose Id is an empty (zero length) string (This is not the same as NULL). And when you update the table the row is trying to relate itself to a student with an empty string ID.
If my guess is correct: You should set StudentID in the BOOK table to be nullable. If the student is to be cleared you should set the value of the column to be DBNull.Value .
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Hello
Thanks for your help. I did what you asked, but l am still having the same problem. As i am using MS Access i can't set the StudentID in the book table to be Nullable.
dtReturnBook.Rows[0]["StudentID"] = DBNull.Value; //Gave a compile error
dtReturnBook.Rows[0]["StudentID"] = DBNull.Value.ToString(); //Gave the same error as the first problem.
The problem remains, l need to clear the StudentID in the book table, as the student no longer has that book.
Any other ways to solve this problem.
Thanks in advance,
Steve
|
|
|
|