|
There's a much more elegant way to do this if the collection has RemoveAll
listnameitems.RemoveAll( delegate(ListItem itemName) { return itemName.Selected; } );
This avoids creating a temporary list, adding items to it and then iterating over it and removing items from the original list.
|
|
|
|
|
Guys need help man
How to convert this vb code
officer.Text = mid(User.Identity.Name, instr(User.Identity.Name, "\")+1, len(User.Identity.Name))
to C Sharp
Thanks A million
KaKaShi HaTaKe
|
|
|
|
|
Hi,
Here is yr c# code.
officer.Text == Strings.mid(User.Identity.Name, Strings.instr(User.Identity.Name, "\\") + 1, Strings.len(User.Identity.Name))
I hope it will help u..
Rana Krishnraj
|
|
|
|
|
Krishnraj,
I don't think it will help him, since it wont work in C#.
Regards,
Gareth.
|
|
|
|
|
|
There are several websites that translate code from Vb to C# or the other way around. Google will help you in finding them if you ask it.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
This is what happens when people use nasty legacy VB stuff.
I think mid is replaced by Substring, instr is replaced by FirstIndexOf and len is replaced by Length, all members of teh string class.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
(via Instant C#):
officer.Text = User.Identity.Name.Substring((User.Identity.Name.IndexOf("\\", 0) + 1), User.Identity.Name.Length);
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB, C#, or Java to C++/CLI
Java to VB & C# Converter: convert Java to VB or C#
|
|
|
|
|
Hi all,
I need open .doc file using richtextbox.I use openfileDialog command to open .doc file.The error was "file format is not valid"..
I had draw some object in .doc file..Is it the problem because of it..?
%#&kmpYrlHSGYG5@#($_+!@!(*JASnjshdk,cm_0ashjhdbn@#$!48mkhfbchsh))^%#W%&@YW7wsdfjw789';'][]\`~JKJQ4$!@#~)-HSKS^&*1)JK12@#@$~!1`DFGkqp][]\]?Zas;EWRG%!@~)(^&BVAG
|
|
|
|
|
richtextbox cannot open word docs.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Are you able to save the doc file as an RTF? I believe richtextbox can handle that.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
Ya i can save .doc file in .rtf format..Nw i can open .rtf file using richtextbox..I drew rectangle using wordpad then save in .rtf format..
Now the problem was, i cant change the rectangle colour inside richtextbox.
So how i can change the rectangle colour.?
%#&kmpYrlHSGYG5@#($_+!@!(*JASnjshdk,cm_0ashjhdbn@#$!48mkhfbchsh))^%#W%&@YW7wsdfjw789';'][]\`~JKJQ4$!@#~)-HSKS^&*1)JK12@#@$~!1`DFGkqp][]\]?Zas;EWRG%!@~)(^&BVAG
|
|
|
|
|
RichTextBox can display rtf files, not doc. There are several controls here on codeproject that allow to display doc files. Search and you'll find them
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Hi,
I'm trying to create a function that will automaticly send me the errors of the application using the MailMessage function from the namespace: System.Net.Mail.
This is the code I have now but for some reason it aint working.
It gives me the following error (sorry it's in dutch):
"Postbus niet beschrikbaar. Het serverantwoord is: 5.7.1 Unable to relay for email@company.nl"
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress("info@company.nl", "Application AutoEmail", System.Text.Encoding.UTF8);
message.To.Add(new MailAddress("email@company.nl"));
message.Subject = "Application error";
message.Body = "This is the content...";
message.Priority = MailPriority.Normal;
SmtpClient client = new SmtpClient();
client.Host = "localhost";
client.Port = 25;
client.Send(message);
MessageBox.Show("Your email has succesfully been send.", "Email send");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
What am I doing wrong?
|
|
|
|
|
Your local SMTP server is not set up correctly.
|
|
|
|
|
Thank you!
I changed "localhost" to "ExchangeServer" (our local mail server) and it worked.
But if the application is running on a computer outside our network, the SMTP host will be different.
So is there a way to determine the SMTP host address/name of the current computer/user?
|
|
|
|
|
If the Exchange server is internet accessible (a fully qualified domain name), then just use that instead so that if you're deploying outside of your LAN, it can still be reached.
If not, then you might need to allow for user configuration to specify the SMTP server name or address.
|
|
|
|
|
Ah ok...
But it's not possible to get the hostname/address from the SMTP server in C#?
|
|
|
|
|
Hi all,
I have a windows service, and I handle three events there like Timer, two port listeners.
OnStop() of the service I want to kill/stop those three events. So, simply I catch the exception as follows.
protected override void OnStop()
{
try
{
TimerTicker.Stop();
LstOne.Stop();
LstTwo.Stop();
}
catch(Exception ex)
{
EventLog.WriteEntry(ex.Source,ex.Message);
}
}
Ok, here is my question. Say the TimerTicker found an exception, OnStop() exit from there and next two event dead, I mean not stopped. How should I handle.
Using separate three function to do this, seems to me odd.
I appreciate your help all the time...
Eranga
|
|
|
|
|
With Seprate try catch block inside one method.
Regards,
Vythees
Miles to go before sleep...
|
|
|
|
|
Thanks for the replay.
Something like this.
try {
}
catch(correct_exception_for_timer) {
}
catch(correct_exception_for_listener) {
}
catch(correct_exception_for_listener_two) {
}
Ok, say on the timer I got the exception. Is that remainders are execution. Like LstOne.Stop() is executed?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
No. He means like this:
try
{
timer.Stop();
}
catch (Exception ex1)
{
}
try
{
FirstOne.Stop();
}
catch (Exception ex2)
{
}
try
{
SecondOne.Stop();
}
catch (Exception ex2)
{
}
"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
|
|
|
|
|
Ok, I got the point. Is that the much better way to do it?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
It's the *only* way to do it if you want to try stopping all of the objects regardless of whether or not one or more of the others stop.
"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
|
|
|
|
|
Logically yes, but the code can be made better by using a more functional approach.
Action [] stopActions = { TimerTicker.Stop, LstOne.Stop, LstTwo.Stop };
foreach(Action action in stopActions)
{
try
{
action();
}
catch(Exception ex)
{
EventLog.WriteEntry(ex.Source, ex.Message);
}
}
|
|
|
|