|
See the documentation for the TreeView.HideSelection property in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is it possible for a ListView to contain SubLists (Kinda like a TreeList, but with more than one item)
For example:
+ TopItem1
+ TopItem2
- TopItem3
|_ ChildItem1 ChildItem2 ChildItem3
|_ ChildItem1 ChildItem2 ChildItem3
+ TopItem4
And you would be able to expand like shown above.
I hope to read your input soon.
Thanks in advance,
Jon
|
|
|
|
|
There is a reason why they are called ListView and TreeView!
You could come up with something like this, but you would have to draw the ListView control yourself. You can look at this[^] article by Jon Rista, here on CodeProject, for a start or just use his control...
RageInTheMachine9532
|
|
|
|
|
What would you suggest I should use to get the same effect?
I don't want to spend too much time on this since I have a lot more left to do, and my deadline is approaching fast.
The look i'm trying to achieve is something like this
www.microsoft.com/money/support/manual/screens/fig7-4.jpg[^]
If you look at the table in the center of the application, you will see what I'm trying to do.
|
|
|
|
|
|
That's for ASP.NET.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Then you'll need to buy a commercial version. This type of control is difficult to do correctly and requires a pretty good working knowledge of .NET, object-oriented programming, collections, etc.
There are several available that aren't very expensive, like XtraGrid[^], WinGrid[^], and more.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you for your comments, I decided to keep my layout a little simpler for the time being.
It still has the same functionality, although its not as pretty
Thanks again.
|
|
|
|
|
I have a C# Windows Form that contains the logic to display an icon in the systray. I have that form hidden (visible = false). When the user clicks the systray icon I unhide the form (visible = true) to allow the user to change some settings. When the user finishes changing the settings he can click the close button (the X in the top right corner).
In the frm.closing event I have this:
this.Visible = false;
e.Cancel = true;
That code will hide the form for later use and it keeps the application from exiting.
Life is good UNTIL the user goes to shutdown the computer. During the shutdown process Windows goes to close my application; but my app sends Windows the Cancel signal and so Windows never shuts down. I’m about ready to hack something up with WndProc but I was hoping there might be some way to tell if whether my app is being closed by Windows or by a click of the close button (the X in the top right corner).
Thanks.
|
|
|
|
|
Implement the IMessageFilter interface and add an instance of your implementation using Application.AddMessageFilter (this can degrade performance severely if not implemented correctly / efficiently). Watch for the WM_QUERYENDSESSION (0x0011, cancelable) or WM_ENDSESSION (0x0016).
Alternatively, you can override WndProc in your main application window (the form you pass to Application.Run , for example) and do the same thing.
Windows sends this message when shutting down. You can return false to attempt to prevent Windows from shutting down (it most likely will), or just return true and close your application or do whatever you need to.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hai,
No matter wether it is a static data member or static member function. i need to access to and fro. to me it is not possible to access a static datamember or static member function to instance data member or member function.
But right now i want to do like that.
Any trick is there in your hand
hai, feel free to contact
Sreejith SS Nair
|
|
|
|
|
Which, of the potentially millions, of instances would you like to access?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event
|
|
|
|
|
What? Can you try explaining a little better?
To access a static member, first make sure the access modifier allows it. It should be public for all code to access it, protected for derivative classes to access it, internal for code in the same assembly to access it, and protected internal for code in the same assembly or derivative code in any assembly to access it. If you're not specifying an access modifier, than members default to private.
Then, just access the member using the Type - not the instance:
MyClass.MyStaticMethod(); If you're calling a static method or getting/setting a static field or property in defined on the same class in which your code is currently executing, you don't have to specify the class name, though I personally find it easier to read.
If you're trying to access instance data through a static member (bad idea), then your instance must get/set itself as a static member like so:
public class MyClass
{
private static object syncRoot = new object();
public MyClass()
{
if (theInstance == null)
lock (syncRoot)
if (theInstance == null)
theInstance = this;
}
private static MyClass theInstance;
public static MyClass TheInstance
{
get { return theInstance; }
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Or the instance could pass itself as a parameter to a static method, but there's no reason to do that instead of creating an instance method. I'm interested to see more information from the poster.
Regards,
Jeff Varszegi
EEEP!
|
|
|
|
|
By definition, no you can't use a Static member to access instance data. Reason being, static members are not associated with ANY instance. They can be used without instantiating an object from the class. Since they are never instantiated, they are also never associated with any other instance and, therefore, can't access instance data.
RageInTheMachine9532
|
|
|
|
|
... unless, that is, there's a static handle to an instance. This question smacks so much of misguided design that I'm interested to see more information from the poster.
Regards,
Jeff Varszegi
EEEP!
|
|
|
|
|
Hi,
I've been trying out stuff in C#, and got to the following problem:
I need to create a list in C#, and send it to a C++ dll together with another value. The C++ dll will add the value to the list.
So, when this concludes I'll have the updated list in my C# program.
This cause a few questions:
1. Is there a list structure in C# (or I'll need to use ArrayList).
2. How can I marshall the list in C++ to anything in C#?
Thanks
|
|
|
|
|
Any implementation of IList is a list (though arrays - which implicitly inherit from System.Array - are static). The problem is marshalling. You cannot just pass the IList to C++ and expect it to work, especially when there's no such implementation in C++.
What list are you using? An STL list ? That determines how you marshal an IList from managed to unmanaged code, and vice versa.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
yep, I understood that my problem is marshaling.
The problem I can't find anywhere an example for this.
My list is an STL list.
|
|
|
|
|
I think it will be pretty safe to say that it is NOT possible to marshal an STL list or anything STL for that matter. I mean templates are simply not supported in C# or VB.NET(they will be supported in C# 2.0). If you can modify your C++ source code, you should look into using a SAFEARRAY or a c-style array for calls that will be P/Invoked. Or you should look into writing a COM wrapper for you C++ class.
|
|
|
|
|
First of all, thank you for your answer.
Secondly, can you think of a data structure that can be marshaled?
List is not a must...
|
|
|
|
|
Is it possible to generate a unique number from a string of say 50-100 characters? Is that what a "hash" is? If so, how do you do it?
NATHAN RIDLEY
Web Application Developer
email: nathan @ netlab.com.au
[remove the spaces before and after the @ symbol]
|
|
|
|
|
Hello!
I'm not a guru but i think MD5 encryption is a solution for this case
Bye
|
|
|
|
|
While it's not guaranteed to be unique, it is mathematically impropable (not impossible) to get the same hash.
You can generate a digest over your string like so:
public string Digest(string value)
{
if (value == null) throw new ArgumentNullException("value");
byte[] buffer = Encoding.Unicode.GetBytes(value);
MD5 md5 = MD5.Create();
byte[] hash = md5.ComputeHash(buffer);
return ConvertToHex(hash);
}
public string ConvertToHex(byte[] buffer)
{
if (buffer == null) throw new ArgumentNullException();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < buffer.Length; i++)
sb.AppendFormat("{0:X2}", buffer[i]);
return sb.ToString();
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hash function definition
When people talk about hashing data, they're passing it through a hash function. Hash functions are one-way functions at least in the sense that data over an unconstrained range may be made to fit into a constrained range; however, it's sometimes possible to figure out possible input values from some output. MD5 is an often-used hashing algorithm. The single most popular use for hashing, in my experience, is to store passwords in a somewhat secure way. Many servers don't store a plain-text version of a password, or can be configured that way; instead, they store the hashed version, and when some client requests authentication, they take the passed password, hash it, and compare it to the hashed version.
Regards,
Jeff Varszegi
EEEP!
|
|
|
|