|
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
|
|
|
|
|
steve_rm wrote:
As i am using MS Access i can't set the StudentID in the book table to be Nullable.
I've not used Access in a few years, so I may be wrong, but you can set Required to No - which is the same as saying Nullable.
steve_rm wrote:
DBNull.Value; //Gave a compile error
Not sure why that would be...
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. I'm working on a performance critical component, and need buffers to work in. I'll only need one buffer per thread, (at most) so I'll store one in thread-local-storage and I'll keep a record on the average needed size, per AppDomain. Thus I'll change the size of the pooled buffers peridocially to the average size (rounded up to the nearest SystemPageSize, which is usually 4K).
So, the question is if this is even a good idea in managed code at all? If I was working in unmanaged code, I'd not even have asked, but now I don't know if it's simply better to call new byte[requiredSize].
|
|
|
|
|
Better is a relative term. If "better" == "safer", then new byte[requiredSize] is better. If "better" == "faster", then you'll get better performance by P/Invoking HeapAlloc or similar. The problem with this approach is that the memory is unmanaged by the CLR so it can't track it. You could marshal it to an IntPtr and use that in managed code, but the buffer is still allocated on the unmanaged heap (or stack if you used something like _alloca ). You'll have to free it explicitly. This is where wrapping such functions in a class following the disposable pattern is handle, and .NET 2.0 will introduce the SafeHandle for just such a purpose. You can either define your own now, or take a look at the GCHandle and HandleRef structs under System.Runtime.InteropServices which may be helpful depending on how you're using the memory (especially if you need to marshal managed types to native memory).
There is yet another way, though. Read about C#'s stackalloc operator keyword. This, of course, will alloc memory on the heap and give you an unsafe (i.e., has access to direct memory and is not GC'd) pointer.
HTH
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 there!
In a program that I´m trying to develop I have a panel that as lot of PictureBox so I put the property AutoScroll equal to true.
Now I´m making a function to remove one PictureBox, in order to do this I´m clearing the panel and then I redraw all the existing pictureBox (I keep all the picturebox in an array). The problem is that, in this process of removing and redrawing, the scroll is moving for the left first (because of the clear of the panel) and then to the right (because the insertion of the picturebox).
What I want to know is how can I make that the scrolling movement don´t happen. After all I´m only removing one pictureBox in thousand of them.
Best Regards, Sérgio
|
|
|
|
|
Why are you removing all the PictureBox es just to remove a single one? Use a little simple math and just reposition all the PictureBox es after the one you removed consecutively. That's much more efficient and much less memory- and CPU-intensive. But if you really do have a around a thousand PictureBox es then memory will alread be a problem for you. Use a more efficient application design where you don't allocate memory for a rich control like the PictureBox for each image when most won't even appear, but draw the images yourself (Graphics.DrawImage makes easy work of this) onto a single control based on the position of the scroll bar which you can manage yourself.
As for your immediately problem, set AutoScroll to false . You may loose the scrollbars temporarily but at least it isn't changing sizes constantly (which is eating even more CPU cycles than you already are by removing all your PictureBox es and re-adding them).
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]
|
|
|
|
|
As you notice, i´m not an expert in programation. I´m usign picturebox because it´s the only manner that I found to solve my problem.
I have a linkedlist with all the elements that I want to put in the panel, and I do something like this...
panelCenas.EnableAutoScrollHorizontal = true;
for(int i = 0; i < cenaslist.LastIndex(); i++)
{
cenasBox = new PictureBox();
cenasBox.Image = cenaslist.GetAtPosition(i + 1);
cenasBox.Tag = cenaslist.GetTagAtPosition(i + 1);
cenasBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
cenasBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
cenasBox.Size = new System.Drawing.Size(96, 72);
cenasBox.Location = new System.Drawing.Point(i*96+1, 0);
cenasBox.MouseMove += new System.Windows.Forms.MouseEventHandler(cenasBox_MouseMove);
cenasBox.MouseDown += new System.Windows.Forms.MouseEventHandler(cenasBox_MouseDown);
cenasarrayList.Add( (PictureBox)cenasBox );
TipCenas.SetToolTip( (PictureBox) cenasarrayList[i], Convert.ToString(cenaslist.GetTimeAtPosition(i+1)));
panelCenas.Controls.Add( (PictureBox)cenasarrayList[i]);
}
panelCenas.VisibleAutoScrollVertical = false;
How can I do this with the Graphics.DrawImage?!!! Could you explain it to me.
Thank you very much, Sérgio
|
|
|
|
|
The way to get better is by reading. In VS.NET's Help index type "Graphics.DrawImage" or search for it on http://msdn.microsoft.com/library[^]. This forum is for helping with specific problems, but only you can teach yourself what you need to know. Not even schools can do that - they merely give you the tools and training with which to start your real education.
Most of the .NET Framework SDK documentation includes samples that should help you. There's also hundreds of articles here on CodeProject, many of which explain how to draw in .NET (just keep your search limited to C# and .NET, which you can check in the search page). That's why this site exists: to help new - and even experienced - programmers.
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]
|
|
|
|
|
Good day all…
I am experiencing a problem in using the Form Icon property. I have created a custom icon for my app and cannot display the icon (in the design view) by setting the property using the browse function. It displays properly in the properties view but not on the title bar. I get a default icon (on the title bar) of which I cannot determine its origin. This icon is not the system default icon.
Thank you very much in advance for your assistance
Have a great coding day.
Regards,
Tony D. Abel
|
|
|
|
|
Open your icon in the icon editor in visual studio (if the .ico file is not part of your project, add it to the project and then double click it to open it in the editor). In the icon editor, there will be an enlarged view of your icon. Right-click anywhere in that view (not on the icon itself) and select "Current Icon Image Types | 16x16, 16 Colors". You should now see the smaller version of your icon which can be edited. If you have not made any changes to this before, then that would explain why your small icon is the default icon.
Hope this helps.
Best Regards.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Good day Matt
Thanks for the assist. I was trying to load a 32 x 32 icon for the title bar.
After changing the icon to a 16 x 16 icon it became present in the form design view.
Have a great coding day.
Regards,
Tony D. Abel
|
|
|
|
|
Hi all,
I want to use RegisterWindowMessage for IPC in pocketPC 2003 ?
Is it possible ? I have tried it by C# but some classes needed are missing
in .NET CF, so I try to find to implement it in VC++ in pocket2003. So what is the corresponding command for register the window message in VC++ ?
Thanks
Patrick
|
|
|
|
|
Hi~
As the message windows instance created in c# not register the window class or window title.(not like C++). So how can i get the handler of a message window which written from C#?
|
|
|
|
|
Hi all,
How to create COM by C# ? I have searched but can't find detail enough information to create it, including the interface...etc.
And can I use the c# com in VB script in a html file ?
e.g. in the VB script, I will program it as,
Set comObject = new CreateObject("comObject")
Thanks
Patrick
|
|
|
|
|
I am currently working on creating a COM+ component using C#. I can't asnwer your question about calling it from an HTML file, however, I have successfully run my COM component from a VBScript on the command line. Do a search on google for System.EnterpriseServices.ServicedComponent (you will inherit from this class to create your component). You will find several articles online that explain how to do it. Once you have successfully created your component, you simply register it with the regsvcs command line tool. Then you will see it in the component services control panel. You then instantiate it from your script as you would any other COM component.
One thing to keep in mind is that while the API to do all of this seems pretty clear, in practice it proves very complex and confusing. I am currently having some problems myself that I hope to figure out soon. Anyhow, let me know if you can't get going. I'll help you out however I can.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Doesn't work as Console.ReadLine return a string:
int x = Console.ReadLine();
...
Console.WriteLine(x);
So how can I convert the string to int (or float or short and so on) ?
String object doesn't seem to have ToInt member either ...
I still can't belive I don't know this one ...
Regards, Desmond
|
|
|
|
|
|
int x = Int32.Parse(Console.ReadLine());
This one will also throw an exception if it isnt a number string
Yuvaraj N
|
|
|
|