|
I have a checked list box that has about 20 items in the list. At a certain time I need to lock the control from the user so no more items can be checked or unchecked. If I set the control's Enabled property to false, the user cannot check any items but they are also prevented from scrolling down the list to see what items are checked.
How do I disable checking but allow the user to still scroll through the list? Thanks!
|
|
|
|
|
You may want to handle ItemCheck event and write some code to decide if item's CheckState value should be changed or not.
|
|
|
|
|
I'm trying to do the following but it does not compile?
<code>struct ProxyHolder<TInterface> where TInterface : class
{
public ProxyHolder(ClientBase<TInterface> client, object clientLock)
{
}
}
Dictionary<Type, ProxyHolder<TInterface>> proxies;</code>
This fails on the TInterface in the Dictionary declaration.
Is there any way of achieving this? For ProxyHolder I can pass in Type instead of TInterface, which would compile but then this code would fail
<code>proxies.Add(typeof(JobManagerClient), new ProxyHolder<IJobManager>(jobManager, jobManagerLock));</code>
with:
Argument '2': cannot convert from '<IJobManager>' to 'ProxyHolder<System.Type>'
Kevin
|
|
|
|
|
Kevin McFarlane wrote: This fails on the TInterface in the Dictionary declaration.
Thats because TInterface is not declared. You will need to specify a type, or move that declaration into the ProxyHolder struct (if possible) where TInterface is defined.
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
So TInterface has to be a closed constructed type right? That's the problem, I don't know in advance what type it should be.
Kevin
|
|
|
|
|
I'm a bit confused about your syntax here. Is IJobManager an interface (I certainly hope so from the name)? You should be able to do this with proxies.Add(typeof(JobManagerClient), new ProxyHolder(jobManager, jobManagerLock)); The compiler should be able to determine the type of TInterface from the TInterface parameter in the ProxyHolder.
-- modified at 8:15 Thursday 29th November, 2007
Scrap the struck out statement. It's gibberish. Thanks to leppie for making me look at it again.
|
|
|
|
|
Pete O`Hanlon wrote: The compiler should be able to determine the type of TInterface from the TInterface parameter in the ProxyHolder.
Definately not the C# 2.0 compiler
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
You're right of course. I don't know what I was thinking of here. I've just relooked at his original post, and the generics are a complete mess. He needs to simplify it a lot.
|
|
|
|
|
Pete O`Hanlon wrote: He needs to simplify it a lot.
How?
Kevin
|
|
|
|
|
Wouldn't this
Dictionary<Type, ProxyHolder<TInterface>> proxies;
need to be this
Dictionary<Type, ProxyHolder<IJobManager>> proxies ;
?
|
|
|
|
|
The problem is I don't know in advance what ProxyHolder is going to hold. I fear that I cannot solve my problem in the way I want. Probably needs a rethink. Basically I'm trying to reduce a whole bunch of if-else tests to a single lookup table.
Kevin
|
|
|
|
|
|
Yes, I'd more-or-less concluded that. Plus, I've now managed to simplify my problem down to a single if-else decision point. That's OK for now.
Kevin
|
|
|
|
|
VS2005
I've added some settings to a program I'm writing, and set the scope to "User", but I can't get it to write new values for those settings. I'm calling Properties.Settings.Default.Save() , but nothing appears to be happening. Since the scope is set to user, I expect to see a user.config file in documents and settings under my user name, but I don't see anything at all.
What could I be doing wrong?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: What could I be doing wrong?
User settings gets saved under the user folder (god knows where), and gets picked up from there if different from the app.config. Note app.config is never changed.
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
|
I'll look there tonite.
However, I don't think it's working because I can't appear to retrieve data I "save"d.
Why does everything in .net have to be so convoluted?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
After a quick look on my system I find the settings files in the following location
C:\Documents and Settings\username\Local Settings\Application Data\companyname\applicationame.exe_Url_4jxa32l1jl5ig3yszvzaymm2fpoq5w4k\1.0.0.0\user.config
where
companyname is that set in the company field of the assembly information
You may end up with several versions of the config file in which case they will have different _Url_4jxa32l1j.... tagged on the end of the exe name.
Alan.
|
|
|
|
|
Those pesky autochanging version numbers always cause me problems.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
John, settings do work exactly like you would expect, but there is apparently something throwing a wrench into it.
Few things to try:
Properties.Settings.Default.MySetting = newValue;
Properties.Settings.Default.Save();
Foo loadedValue = Properties.Settings.Default.MySetting; Does loadedValue == newValue in that case?
Another thing to try, if you save a setting as above, then restart your application (don't rebuild it, just restart it), does your saved setting stick?
If the above 2 things work, try saving a setting, rebuilding your application, then loading that setting. If the loaded setting isn't what you saved, then I'd check your AssemblyInfo.cs (under Properties project in your folder) and verify the version numbers aren't auto-incremented each build, e.g. 1.0.*
|
|
|
|
|
I'll bet it's the version number thing. I'll check it tonight. Thanks you magnificent human being (in case it works), and you worthless bastard (if it doesn't work).
BTW, I don't recall manually editing the assemblyinfo.cs file, but I'll check anyway.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I just tried a simple app here at work (running Vista), and it appears to work fine. I'm running vista here, and it put the file into
c:\users\me\appdata\local\companyname\appname.exe_Url_some-huge-ass-hash\1.0.0.0\user.config
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I have no idea if this helps, but a few weeks ago I was toying around with a WPF application on XP. I would save my settings, but the next time I launched the program, it didn't see my new setting. It was like it was never saved in the first place.
I thought it was a limitation of WPF, but I built a test WPF app and it worked fine there. I checked and made sure the auto-increment version number wasn't set, tried all kinds of things. In the end, I just created a new C# project and copied the files over to that one, the settings magically worked. It was as if that particular C# project's settings were cursed. In 6 years of .NET development, I had never seen an unexplainable case like this. Maybe this is what you're experiencing.
|
|
|
|
|
Every time i make a program and send it to a freind or relative, they tell me it doesn't work.
I upload it to my other computer and it doesn't work on there either, how do i fix this problem?
|
|
|
|
|
Just as a guess, I would suspect that they don't have the .NET framework installed. There is a redistributable available for each different version of the framework that allows you to install it for them.
|
|
|
|