|
Hi all
How to prevent user check on checkbox of a listview control. The listview control contains many of row items which can be selected by clicking on the checkbox. But now I want to prevent user click on the checkbox. I will check them by code in program.
And the listview control will be still active. That means user still selects one row item but just cannot click on the checkbox.
Anybody help me
thanks in advanced!
[N][Q][H]
|
|
|
|
|
Assuming this is Forms...
Maybe you could handle the ListView.ItemCheck event, and in
your handler check if the ItemCheckEventArgs.NewValue is
different from the ItemCheckEventArgs.CurrentValue, and if so,
set the ItemCheckEventArgs.NewValue to ItemCheckEventArgs.CurrentValue.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
[N][Q][H] wrote: But now I want to prevent user click on the checkbox.
Why would you offer the user a checkbox if you don't want them to be able to use it?
|
|
|
|
|
Actually, I am trying to send message to a listview which does not allow me click to the checkbox. This is a trainning for a online game. Since character'level less than 10 I can click on the checkbox and this trainning will train my character. but if character'level greater than 10. The trainner will not allow me click to the checkbox.
In the first case(level < 10). I have tried send message to click the first row items. It works properly.
ListView_SetCheckState(hwnd,0,true);
But when my character'level reachs to 11. The list view seems be blocked(Notice that listview still be actived). In this case, the code does not work. I cannot only click to the checkbox but also using ListView_SetCheckState.
I guest that I need to send a message to update the property of listview before I can use ListView_SetCheckState. But what needs to be updated?
Plz help me!
thanks
[N][Q][H]
|
|
|
|
|
[N][Q][H] wrote: But when my character'level reachs to 11. The list view seems be blocked(Notice that listview still be actived).
I'm not sure what you are saying here; can you explain how this affects the ListView? Can you also show us the code that is affected?
|
|
|
|
|
how about e.Handled = true in eventHandler, or disabling the check box.
HTH,
|
|
|
|
|
I always have trouble debugging methods (doing a watch, for example) over methods that pass some information to another thread and wait for the result, as the other thread is keept suspended while evaluating is done.
Is there any way to mark a thread to be "invisible/unstopable" by the debugger?
|
|
|
|
|
AFAICT, there's no way to do this. Once the app breaks in the debugger, all threads stop along with it.
|
|
|
|
|
I made a big mistake. The code bellow tells everything:
private void SearchFolders(FileSystemInfo[] fsInfos)
{
foreach (FileSystemInfo fsi in fsInfos)
if (fsi is FileInfo)
try
{
ReplaceInFile((FileInfo)fsi, "textToSearch", String.Empty);
}
catch {}
else if (fsi is DirectoryInfo)
SearchFolders(((DirectoryInfo)fsi).GetFileSystemInfos());
}
private void ReplaceInFile(FileInfo fi, string searchText, string replaceText)
{
StreamReader reader = new StreamReader(fi.FullName);
string content = reader.ReadToEnd();
reader.Close();
content = Regex.Replace(content, searchText, replaceText);
StreamWriter writer = new StreamWriter(fi.FullName);
writer.Write(content);
writer.Close();
}
So i have a recursive function SearchFolders witch searches an expression in all files from a folder. The problem: well i forgot to put the condition that the search should be done only on text file. So the function just executed on every kind of file (jpeg, gif, pdf, doc, etc.). The result: the files are unreadable. Tryng to reverse the proces with someting like this had no result
private void Reverse()
{
FileInfo fi = new FileInfo(@"D:\test\test.jpg");
FileStream fs = fi.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
StreamReader sr = new StreamReader(fs);
string content = sr.ReadToEnd();
System.Text.UTF8Encoding utf8 = new UTF8Encoding();
byte[] bytes = utf8.GetBytes(content);
FileStream fstarget = File.Create(@"D:\test\reverse.jpg");
fstarget.Write(bytes, 0, bytes.Count);
fstarget.Close();
}
I think the files are lost but i just want to hear and another opinion.
|
|
|
|
|
cristi82gt wrote: ReplaceInFile((FileInfo)fsi, "textToSearch", String.Empty);
No, it's not reversible. What you did was replace every occurance of a certain text with nothing. Now you have no idea where to put the text back into the files. If you replaced it with a known string, that would be different, but since you used String.Empty, you've lost any hope of knowing where to put back the bytes you took out.
The bottom line is those files are hosed up beyond repair.
|
|
|
|
|
Thanks for the answer Dave. Well i don't want to bring the text files to the way they were before, only the other types of files (jpeg, pdf).
Let's neglect for a little the function ReplaceInFile , because the expression to replace was pretty long (around 60-70 characters) and i don't think that in an image read as text would find it(very improbably)
The problem is that i read an binary file(for example an image-JPEG) with a StreamReader (UTF8 encoding) as a string, than i wrote that text with a StreamWriter overwriting the original file. (the function i wrote was clearly meant for text file but i forgot to limit it only to those type of files)
The problem is that the image file is now unreadable because it has been written as a text file with UTF8 encoding. I know that in case of Base64Encoding reading a binary file as text wouldn't be a problem, because the text can be reverted back to bytes so that would again compose a valid image(jpeg) for example
In the case i did i don't think this is possible. Any ideas?
|
|
|
|
|
I'll ignore that you shouldn't have written a file that you didn't change...
Since the conversion from binary to UTF-8 is "lossy", there is no way to go backwards.
|
|
|
|
|
OK thanks again Dave. That's all i wanted to hear.
|
|
|
|
|
To which is passed like destination a project, and generates Web Service and publishes to in Internet Information Server.
in Visual Studio 2008. to Framework 3.0 or 3.5 in c#
Existe alguna función en el Framework de .net, que pasándole el destino de un proyecto creado en Visual Studio, me genere del proyecto un Web Service y me lo publique en Internet Information Server.
Gracias
|
|
|
|
|
Please don't cross post. You have asked the same question in ASP.NET Forum.
|
|
|
|
|
Hi all,
I have created a windows application,in that 1 MDI parent and 2 child forms are there....i have opend 2 child forms,now if i add anything in the first window textbox that should get updates in the second window's dropdown,bcz the value which i entered in the first window is get stored in the database,and the second window dropdown is populating form that table...
This is not happening...how to do?...
(2 windows are of child of the same parent window..)
Thanks in advance...
|
|
|
|
|
The simplest way is to create a method in form2 that refreshes the dropdown and call this method from form1 when text is entered in the text box. But and ideal solution would involve using delegates to achieve loose coupling.
Hope this helps,
Shameel
|
|
|
|
|
Ok, I first want to say that I am VERY new to visual studio 2008. So, this may be an easy question to answer for many of you. I have created 10 forms and what I noticed is that 7 of the forms have the same controls. The other 3 forms have have the controls as well but 3 addition controls have been added to the form. My question is 2 fold. One, how do I copy or clone one of these forms including the code to another new form. I have tried a few things in the past but the controls do not stay in the same location so I am sure I have yet to find the right way to do it. The second question would be what way would you handle this situation. Let's say you have your form and that form has 4 controls. You need another form that has all the same controls and properties as the previous form but with an additional 2 controls. Is the parent/child method the only way to do this and if so what limitations with classes and objects. Considering, I am a begginer any help would be appreciated.
Thanks
|
|
|
|
|
What you are talking about is called 'Visual Inheritance' in .Net/VS.
You didn't say which language but here is a link[^] for VB.Net, it uses a previous version but is still relevant, and another[^] for C#.
If you google for vb.net visual inheritance or c# visual inheritance you will find lots of help.
And here[^] is a sort of tutorial with code download for both languages.
Hope this helps!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Very confused here!
I can't work out how the runtime changes the border of my button to orange from blue when the mouse pointer hovers over it!
Because no mouse event handlers are defined in the application, so where is this behaviour coming from??
Clearly if this was a web app, I could easily guess that some client script was doing this, but it is simply an ordinary .NET 3.5 windows app!
|
|
|
|
|
mnemonic69 wrote: Because no mouse event handlers are defined in the application, so where is this behaviour coming from??
This is the default behaviour of the control. Take a look at this information on MSDN[^] for further details.
|
|
|
|
|
Hi,
I did take a look at MSDN and it doesn't explain what that 'standard behaviour' is or how that 'standard behaviour works'
Thats why I thought, someone on here might know the answer!!
|
|
|
|
|
mnemonic69 wrote: I did take a look at MSDN and it doesn't explain what that 'standard behaviour' is
Yes, sorry, but as usual Microsoft tend to hide this sort of detail deep in the reference guides. I had assumed that a link to the Button control would give you what information you sought. Suffice to say that you can overrirde almost everything in your application just by changing properties and/or implementing event handlers.
BTW, does the lack of this information prevent you from completing some part of your work?
|
|
|
|
|
I think you are talking about the Luna theme in Windows XP. It is taken care by Windows XP and you don't have to worry about it. Change your Windows theme to Classic and you will see what is happening.
Regards,
Shameel
|
|
|
|
|
;?xml version="1.0" encoding="utf-8"?&gt;
&lt;dataConfiguration&gt;
&lt;xmlSerializerSection type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&gt;
&lt;enterpriseLibrary.databaseSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" defaultInstance="Database Instance" xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data"&gt;
&lt;databaseTypes&gt;
&lt;databaseType name="Sql Server" type="Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase, Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /&gt;
&lt;/databaseTypes&gt;
&lt;instances&gt;
&lt;instance name="Database Instance" type="Sql Server" connectionString="Server=awsqlt25vs01;Database=SW2_phone_interview;Integrated Security=true;" /&gt;
&lt;/instances&gt;
&lt;connectionStrings&gt;
&lt;connectionString name="Server=awsqlt25vs01;Database=SW2_phone_interview;Integrated Security=true;"&gt;
&lt;parameters&gt;
&lt;parameter name="database" value="SW2_phone_interview" isSensitive="false" /&gt;
&lt;parameter name="Integrated Security" value="true" isSensitive="false" /&gt;
&lt;parameter name="server" value="awsqlt25vs01" isSensitive="false" /&gt;
&lt;/parameters&gt;
&lt;/connectionString&gt;
&lt;/connectionStrings&gt;
&lt;/enterpriseLibrary.databaseSettings&gt;
&lt;/xmlSerializerSection&gt;
&lt;/dataConfiguration&gt;
I have the above code snippet in my windows application. Now in some methods I am getting tome out exception. So I need to add one more instance for Microsoft.Practices.EnterpriseLibrary.Data.SQL.SQLCommandWrapper to set the connection time out property for a constant value in config file
Please advise
Thanks in advance.
-
|
|
|
|