|
Hi,
try to use the RowValidating event instead. It has a Cancel property which you can set to true when the fields are not set correctly. Haven't used it so far but I think it should be what you need.
Robert
|
|
|
|
|
With your cooperation i solved my problem.
Thank you very much. I expect welcome from you.
|
|
|
|
|
Hi,
I am stuck on this line of code from VB.NET which I am trying to convert it to C#, Dim str As String = Regex.Replace(SomeString, "<br>", Chr(10)).
I'd tried ((char)10).ToString(), @"\n", Environement.NewLine, Convert.ToChar(10) but nothing helps.
The 'SomeString' is suppose to be some HTML text like <a href="/">Home</a> and after runnng the Regex.Replace, it is suppose to be 'Home' on 'str' where all the HTML codes are being scrap off.
Hope you can help me on this.
Jie Liang
|
|
|
|
|
Hello
To convert that to C# will result in.
string str = Regex.Replace(SomeString, "<br>", "\n");
Remember to include
using System.Text.RegularExpressions;
in the top of the file.
Kind Regards,
John Petersen
|
|
|
|
|
Hi John,
Thanks for the speedy reply. It doesn't really work. Let me show you more of the code.
tag = new Regex("<[^>]*>", RegexOptions.IgnoreCase); <--This was suppose to help me get rid all the HTML text which it works in VB.NET and don't seems to work in C#
for (counter = 0; counter <= PageText.Count - 1; counter++)
{
string str = Regex.Replace(PageText[counter].ToString(), " ", "\n");
str = tag.Replace(str, "");
str = Regex.Replace(str, " ", ""); <--By this line, all the HTML text should be alredy gone
str = Regex.Replace(str, "^\\s+", "");
str = Regex.Replace(str, "\\s+$", "");
PageText[counter] = str;
}
So if this Notify me by e-mail if someone answers this message pass into PageText[0] and send to process, it should left only "Notify me by e-mail if someone answers this message".
Hope I didn't confuse you, thanks in advance
Jie Liang
|
|
|
|
|
Use the "Ignore HTML" option when you post code that inlcuded html code.
Now there is a lot of the code missing, so I can't really tell what you are trying to do.
Why don't you use the string.Trim method instead of inventing a new one?
---
b { font-weight: normal; }
|
|
|
|
|
Ok Jie Liang
As guffa said, you should mark the Ignore Html option when posting code here.
I tried to set up a test case which resembles your code. It works for me. I post the code here.
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Text.RegularExpressions;
namespace Tester
{
[TestFixture]
public class Class1
{
public string Process(string[] pageText)
{
Regex tag = new Regex("<[^>]*>", RegexOptions.IgnoreCase); //This was suppose to help me get rid all the HTML text which it works in VB.NET and don't seems to work in C#
int counter;
for (counter = 0; counter <= pageText.Length - 1; counter++)
{
string str = Regex.Replace(pageText[counter].ToString(), "<br>", "\n");
str = tag.Replace(str, "");
str = Regex.Replace(str, " ", ""); // By this line, all the HTML text should be alredy gone
str = Regex.Replace(str, "^\\s+", "");
str = Regex.Replace(str, "\\s+$", "");
pageText[counter] = str;
}
return pageText[0];
}
[Test]
public void TestFunc()
{
string[] PageText = {
"<label for=email_notify>Notify me by e-mail if someone answers this message</label>"
};
Process(PageText);
}
}
}
The output from the Process method is "Notify me by e-mail if someone answers this message"
Kind Regards,
John Petersen
|
|
|
|
|
Hi John, Hi Guffa,
Sorry bout the Ignore HTML thing, I forgot to check it when I modify my post.
Yes, it works, John. After reading your post, I decided to test this small piece of code and as you said, it works. Then I realized I did not show you enough information, sorry about that.
The HTML code that pass into PageText[] should be in full such as '<a href="">Hello</a>' and not 'a href="">Hello</a>', or else it won't digest the HTML.
Now everything's fine, thanks a lot to both of you, you have been very helpful
Jie Liang
|
|
|
|
|
I have two listviews in my app. The user may make multiple selections in one of them, but may not have selections in both at the same time. To enforce this requirement I'm responding to the SelectedIndexChanged event and having it clear the selections in the other LV. The problem is that the clear() method operates incrementally and immediately fires the event in the listview it's working on, which results in both listviews clearing each others selections. I tried using the lock statement, but the second event handler is able to gain the lock even though the first hasn't completed. Since all the examples I've seen are for controlling across threads I'm assuming the problem is that the second event handler is being ran in the same thread as the first.
What happens is the following:
State: LV1 - 2 items selected, LV2 0 items selected
Click on an item in LV2
State: LV1 - 2 items selected, LV2 1 items selected
LV2 handler called. LV1.Clear method called.
LV1.Clear cancels the 1st selection in LV1
State: LV1 - 1 items selected, LV2 1 items selected
LV1 handler called. It calls LV2.Clear called.
LV2.Clear cancels the selection in LV2
State: LV1 - 1 items selected, LV2 0 items selected
second LV2 handler called. Terminates because LV2 has no items selected.
LV1.Clear() called by the first LV2 handler regains control. Remaining LV1 selection is now cleared.
State: LV1 - 0 items selected, LV2 0 items selected
The result I want is: State: LV1 - 0 items selected, LV2 1 items selected
I could use a bool flag as a psuedo-lock to control the updates but am hoping there's a more graceful way to do it.
LV2 has a handler identical to this.
private void LV1SelectedIndexChanged(object sender, System.EventArgs e)<br />
{<br />
lock(this)<br />
{<br />
if (this.LV1.SelectedItems.Count >0)<br />
{<br />
this.LV2.SelectedItems.Clear();<br />
}<br />
}<br />
}
|
|
|
|
|
Sometimes the simple solution is the best. Try removing the event before clearing the listbox and adding it again afterward. Not elegant, but works.
only two letters away from being an asset
|
|
|
|
|
Hello
If you don't want to use bool psuedo locks, you could unregister the other event handler and reregistring it again after making the changes.
EventHandler MyLV2Handler = new EventHandler(LV2SelectedIndexChanged)
private void LV1SelectedIndexChanged(object sender, System.EventArgs e)
{
if (this.LV1.SelectedItems.Count >0)
{
LV2.SelectedIndexChanged -= MyLV2Handler;
this.LV2.SelectedItems.Clear();
LV2.SelectedIndexChanged += MyLV2Handler;
}
}
Regards
|
|
|
|
|
this could work, except that I'd need to move the event handler installation from the designer to user edited code so that it would be available to remove/readd.
|
|
|
|
|
Hi!
I think you have a misconception of lock() here...
lock(obj) is used to prevent two or more different threads from entering the same critical section.
Both listviews are handled by the same thread - the UI thread and the listviews are just regular win32 common controls underneath which are sending their windows messages to the thread's message queue.
It's because of these queued messages that your listviews receive their SelectedIndexChanged events...
Removing and re-adding the eventhandlers, as the others have suggested, seems a bit clumsy to me.
As you wrote, a boolean pseudo-lock seems to be the easier solution.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Hello!
I'm trying to use the PStoreC.dll (Windows Protected Storage -- Internet Explorer, Outlook, etc. are storing their passwords in this).
I added a reference to PStoreC.dll . After using the PSTORECLib namespace, there are several classes available now. When I try to construct an instance of the main class (CPStoreClass ), I get the following COM error:
Retrieving the COM class factory for component with CLSID {5A6F1EC3-2DB1-11D0-8C39-00C04FD9126B} failed due to the following error: 80040154.
Do you have any idea how to fix this? I already tried to use regsvr32 to register the PStoreC.dll file, but this unfortunetely doesn't help anything, the same COM exception is thrown...
Best regards
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Hi Dominik,
Try to register the dll using regsvr32.exe
if you still get the same issue then
that means that you are trying to register a non COM server DLL.
All COM server DLL's should have the DLLRegisterServer entry point.
Regards,
Bhupesh.
|
|
|
|
|
i finsh makeing my Winapp
now i want to make setup file
my qyestion
* how can include the .Net FrameWork in my setup ...
and instual it if the computer dont have it . ???
Palestine
|
|
|
|
|
Hello
Right Click on your Setup projects name in solution Exploere => Properties => Settings => Prerequisites => Check .Net FrameWork => From the radio buttons below check "Download from same location as my application"
Regards
|
|
|
|
|
Is there any method for creating a new .net solution from any other .net solution and we can add all the referenced DLL's projects and all kind of stuff in such a manner that when u visit that new solution u should be able to directly build the software.
In short my need is that there are different componets available and i have to create a new solution using this different components(projects).
Plz answer as fast as possible.
Is ADD-Ins Capable of solving my problem.
|
|
|
|
|
Hello
Your question is not clear. What are you trying to do:
1- Make a program that makes C# projects at runtime?
2- Make a project from an existing one to inherit its references?
3- Choose between several projects and merge the chosen ones into one big project?
4- More than one of the above?
Please post more details.
Regards
|
|
|
|
|
yes 1 and 3 is the options that i want to perform. That is a program should be able to make new c# projects at the run time and also several small projects can be added into it at run time.
Sorry that my question was not clear and u were not able to recognize it.
Regard
|
|
|
|
|
Hello
Well, yes VS add-ins can do it. Here is an Article[^] about it.
Yet, first you should understand the structure of VS project files. If you do, you can write an odinary exe program to mix up or segregate different projects based on theri files.
Regards
|
|
|
|
|
Hi
I need to use MD5 technics for encripting & decripting the password.
So if any body knows about that, plz give me an idea to use the MD5 technics.
Just give me some example that to know the process.
Thanking u
Regards,
Naren.
please help me
|
|
|
|
|
MD5 in itself can't be 'decrypted'.
MD5 is a hash. It is commonly used to store passwords in the following manner:
Step 1) The user signs up and enters his/her password, where it is MD5ed and stored locally.
Step 2) The user logs on with a password, which is MD5ed and compared with the local hash.
I'm sure you can find an article on MD5 on google or here on codeproject.
|
|
|
|
|
MD5 hashing is one way, so you can't 'decrypt' it as such. You'd usually use it to store passwords in a file or database so they're not readable by anyone with access to the database. When someone comes to log-in, you hash the password again and compare the hashed passwords to see if they're entered the correct one.
.NET has a built in function for this:
string hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile("Password to Hash", "MD5");
http://msdn2.microsoft.com/en-us/library/system.web.security.formsauthentication.hashpasswordforstoringinconfigfile.aspx[^]
Regards,
Rob Philpott.
|
|
|
|
|
My App keeps on throwing a System.OutOfMemoryException on the e.Graphics.DrawCurve(...) line. Any Ideas?
private void Charges_Paint(object sender, PaintEventArgs e)
{
if (activeParticles < 1)
return;
Pen myPen = new Pen(Color.FromArgb(128, 0, 0, 0), 2.0f);
for(int i = 0; i < activeParticles; i++)
{
if (myParticles[i].Charge)
myPen.Color = Color.FromArgb(128, 255, 0, 0);
else
myPen.Color = Color.FromArgb(128, 0, 0, 255);
e.Graphics.DrawCurve(myPen, myParticles[i].GetCurve());
}
}
|
|
|
|