|
I thought I could, but when using the object as the argument, I get an error
myNode = new TreeNode(df);
"Argument '1' cannot convert '...DetailFob' to 'String' "
Sorry if this is so simple. I did try this before posting.
|
|
|
|
|
Hi,
sorry I was wrong (I use ListBox a lot, and TreeView very rarely).
In ComboBox and ListBox, you can add arbitrary types as items to the list, and what you see is its ToString result (unless OwnerDraw is in effect); however in a TreeView the items have to be TreeNode instances (the tree needs a standard way to find its branches and leaves, a ComboBox/ListBox doesn't have any hierarchy) and what you see is the TreeNode.Text
I see basically two ways to store more than just a string in a TreeView node:
1. create a TreeNode as you did, and store a reference to your object in the TreeNode.Tag property, which is there for you to use any way you like; you still have to provide a Text to the TreeNode (which you did), and if you want Find() to be successful, you should also set the Name property to the text value.
2. create a new class, say MyTreeNode, inheriting from TreeNode. You still need to explicitly set the Text property (as well as Name for a successful Find), but you no longer need to use Tag. As we don't have multiple inheritance nowadays, if you wanted to store say a Form in a tree (Form inherits from Control), you would have to use the first way (with Tag).
The main difference between both methods is the Tag indirection: the first item would be myTree.Nodes[0].Tag in (1) and myTree.Nodes[0] itself in (2)
|
|
|
|
|
Thank you very much for your time Luc.
|
|
|
|
|
you're welcome.
|
|
|
|
|
Store the selected node into Treenode. After that you can get all properties of node through object of treenode.
|
|
|
|
|
In short, I need to be able to do this:
http://i6.photobucket.com/albums/y210/notsotragichero/Chrome.png[^]
I need to be able to add a small image in exactly the same spot Google has done here in Vista / 7.
I have tried numerous solutions over the past week, but can not get this to be fully functional. Even once the image is painted, the NC area will not refresh, unless it is clicked off of, even when using RedrawWindow(). It shows the painted image, and an un-rendered border / titlebar.
[DllImport("user32.dll")]<br />
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);<br />
<br />
private void OnTimer1Tick(object sender, EventArgs e)<br />
{<br />
RedrawWindow(this.Handle, IntPtr.Zero, IntPtr.Zero, 0x0400 | 0x0100 | 0x0001);<br />
}
*The tick is just for current testing purposes*
Is there something, hopefully simple, that I am missing?
Thanks,
Brandon
|
|
|
|
|
The best thing I know is to use a form without borders and do your own form borders. You can see that on chrome, msn messenger, media player and more.
If you do find a way to draw on that area, please post your answer.
Thanks
|
|
|
|
|
I know this is question that has been asked before, but things change, new projects emerge, etc., and I was hoping to get some recommendations.
Basically all I am looking for is a halfway decent free (or cheap) .NET Winforms WYSIWYG HTML editor control. I have played with a couple old .NET 1.{0,1} controls and while they render and generate html output, the ones I have found tend to have serious usability problems (such as not really accepting newlines correctly or 100% of the time.
Thanks for your time
--Scott
|
|
|
|
|
The only decent one I've found so far is Lutz Roeders: Writer[^] .
However, you have to do some modification to it because he has written it to be a standalone app. (Source code is provided)
If my answer has helped you, one of my articles may also be a help. Also remember that your best friend's name is google.
|
|
|
|
|
Thanks - Looks good, I'm getting scrubbed up for surgery now
|
|
|
|
|
thechillhacker wrote: I'm getting scrubbed up for surgery now
Let me know how it turns out. One thing that discouraged me from using it was that it doesn't seem to respond to normal .Net events: Click, MouseDown, etc. Maybe I just didn't do enough surgery.
If all goes well, I highly encourage you to zip the code and post an article about it.
Cheers!
Richard
If my answer has helped you, one of my articles may also be a help. Also remember that your best friend's name is google.
|
|
|
|
|
Hi
In C# (other .Net OOP languages as well), I have 2 webservices. Svc1 returns a complex datatype which becomes the parameter for svc2. Note that it is the same complex type.
Now, I create the 2 proxy classes of these 2 webservices. Which means the same type gets generated twice.
How can I make sure that in 2 proxies only one copy of that type is there? You may assume same or different namespaces of 2 webservices.
Thanks
AJ
Follow your goals, Means will follow you ---Gandhi---
|
|
|
|
|
mittalpa wrote: You may assume same or different namespaces of 2 webservices.
Sounds like a homework question to me. Try google.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
I did .. but not sure how to exactly word it in search. that's why this post.
thanks anyway..
Follow your goals, Means will follow you ---Gandhi---
|
|
|
|
|
Hi everybody, I've made a POS System and @ the exit I want to make an automatic Backup which copies the database to some place ... but it says the database is used ... & I tried to find where it is unclosed (it is thousand of lines of code).... and I cant get it ... so can anybody help me ... how write some line of code which will close any opened connection to that database? ..
Thank you
|
|
|
|
|
Perhaps Management Studio has the database open? If so, you have to close Management Studio; I don't think you can close another application's connection, at least it shouldn't be your standard operating method.
modified on Thursday, December 3, 2009 2:19 PM
|
|
|
|
|
I didnt get what you said... Can you elaborate it to me
|
|
|
|
|
I knew that... but wat i wanted is how to close all connections that are opened @ that time
|
|
|
|
|
Do you know how to use google?
I tried with - "kill connections sql server" and all of the top 10 results had the answer.
|
|
|
|
|
BUT, to kill connections (not your own) you need sa rights, not something which most accounts should have.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Yap, this is true, but if you are building an administrative module you should grant this kind of rights to the admin of the application.
|
|
|
|
|
Shorgov wrote: you should grant this kind of rights to the admin of the application.
Matter of opinion. It allows far to much damage to be done - do you really want to give a user the right to drop tables etc?
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Only to the appropriate user
In general I am agreed with you, but user not allays means dumb person. User of this admin module can be a developer(responsible for the maintenance of the system ) or a trained consultant who knows what he is doing.
|
|
|
|
|
Dear friends..
i have small problem ..
this is my code
private DateTime convertByteToDatetime(byte[] Data)
{
try
{
DateTime now = DateTime.Now;
byte[] year = new byte[2];
year[0] = Data[0];
year[1] = Data[1];
int nYear = convertByteToInt(year);
DateTime dt = new DateTime(nYear, (int)Data[2], (int)Data[3], (int)Data[4], (int)Data[5], (int)Data[6]);
return dt;
}
catch
{
return (null);
}
}
in Catch block i can't return null because Datetime is value type
i do not want to return any date if there is an error....
What shall i do..
Any idea.? suggestion?
By
joe
|
|
|
|
|
You have two options. You could return default(DateTime); or change the return type to Nullable<DateTime>
[edit] You could also rethrow the exception. I find this a tad ugly, but whatever works for you
modified on Thursday, December 3, 2009 12:05 PM
|
|
|
|