|
Thanks sir,
I'll first going to try with the deletion from reverse order as you said. Basically removing the foreach loop. If I'm fail with try to use a duplicate list and work on. I don't like much to use it, because it can use much memory.
I'll let you know what happened.
Thanks.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
The typical solution can be like
for(int selectedItemIndex = View1.SelectedIndices.Count; selectedItemIndex >= 0; selectedItemIndex--)
{
View1.Items.RemoveAt(View1.SelectedIndices[selectedItemIndex]);
}
|
|
|
|
|
Close
Maybe it should be
int selectedItemIndex = View1.SelectedIndices.Count - 1
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
yeah,
the code will be fixed after IndexOutOfRangeException had been occured.
|
|
|
|
|
A simple while loop will do it.
while (listBox1.SelectedItems.Count != 0)
{
listBox1.Items.Remove(listBox1.SelectedItems[0]);
}
|
|
|
|
|
No, my way is FAR better.... :P
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Christian Graus wrote: No, my way is FAR better
Might be. But, when I checked your replies, it included more steps
|
|
|
|
|
I thought we don't have FAR in 32-bit operating systems.
|
|
|
|
|
In vb I have a class from the OM that I set as a global variable - gMT = new OM.clsMasterTables. This holds the tables in memory for all the static table data, for use in combos and lists etc. If a user modifies a master table the form removes the table from the object (gMT.TableName = nothing) and next time it is used it is refreshed from the database.
I would like to achieve this in C#. I am having a problem scoping the instantiation of the gMT object. This is my startup class, the enum is avaialble but gMT is not
static class clsMain<br />
{<br />
[STAThread]<br />
static void Main()<br />
{<br />
Application.EnableVisualStyles();<br />
Application.SetCompatibleTextRenderingDefault(false);<br />
<br />
CSDUserOM.Credentials oCreds = new CSDUserOM.Credentials();<br />
oCreds.Server = "localhost";<br />
oCreds.Database = CSDUserUI.Properties.Settings.Default.Database;<br />
oCreds.UserID = CSDUserUI.Properties.Settings.Default.UserID;<br />
oCreds.Password = CSDUserUI.Properties.Settings.Default.Password;<br />
oCreds.Integrated = true;<br />
CSDUserOM.clsMain.SetCredentials(oCreds);<br />
<br />
<br />
Application.Run(new frmMain());<br />
}<br />
<br />
public static CSDUserOM.clsMasterTables gMT = new CSDUserOM.clsMasterTables();<br />
public enum enSecurity<br />
eUser }<br />
}
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You may want to put the gMT in frmMain rather than clsMain.
|
|
|
|
|
Hey, I was wondering if anyone can help me with trimming a string array. I am calling an API that returns this (At bottom of post).
I am then using this to convert that into a string array
string[] apiresult = new string[25];
char[] splitter = { ';' };
apiresult = result.Split(splitter);
My question is, how do I trim the string array so it just contains
success<br />
1<br />
Bob<br />
etc...
instead of
result=success<br />
userid=1<br />
firstname=Bob<br />
etc...
result=success;userid=1;firstname=Bob;lastname=Smith;companyname=Smith Enterprises;email=bsmith@boostplatform.com;address1=1 Smith Drive;address2=;city=Bobtown;state=Bobstate;postcode=12345;country=US;phonenumber=419-123-4567;notes=TESTING ACCOUNT!!;password=bsmith;status=Active;credit=1010.00;taxexempt=;language=;lastlogin=No Login Logged;billingcid=0;domainemails=;generalemails=;invoiceemails=;productemails=;supportemails=;
|
|
|
|
|
you need to take each string and split it on the =. So, this is a two step thing. you need to iterate over the one set and split each string to get the second set.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Othr than CG suggested, you can try this also
string[] apiresult = result.Split(';', '=');
List<string> expectedList = new List<string>(apiresult.Length / 2);
for (int i = 1; i < apiresult.Length; i = i +2)
{
expectedList.Add(apiresult[i]);
}
Splitting is done in single step here.
|
|
|
|
|
Thanks, but I don't want the firstname, lastname, etc... part of the array. Just the actual answers (Bob, Smith, etc...)
|
|
|
|
|
I'm looking for a PDF Library that will open a PDF and add bookmarks to it and display the final PDF for quality checks. Also, the pdf may be in version 1.7.
GSC
|
|
|
|
|
Have you tried google ? There's plenty of commercial libraries out there.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Yep,I have, just curious to see what experience anyone had. Instead of going through them all, I figured someone knew of a good one.
GSC
|
|
|
|
|
I'm trying to create an email class with a NewMessage procedure that returns an instance of a message class. It errors with "Inconsistent accessibility: return type Stuff.Email.Procedures.EmailMessage' is less accessible than method 'Marois.Email.Procedures.EmailProcedures.NewMessage()'"
using System;
namespace Stuff.Email.Procedures
{
public class EmailProcedures
{
public EmailMessage NewMessage()
{
return new EmailMessage();
}
}
internal class EmailMessage
{
}
}
Everything Makes Sense In Someones Mind
|
|
|
|
|
A method that calls NewMessage() wouldn't have access to EmailMessage.
|
|
|
|
|
I was hoping to have the EmailMessage class invisible to outside classes, and only make it accessable from the main class.
How do I code this?
Everything Makes Sense In Someones Mind
|
|
|
|
|
If it's invisible, you can't return it. That's the issue. You can make the constructor inaccessible and have a factory method, so that users can't create one, but they can ask for one.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
That is because you have a public method EmailMessage, returning a less accessable object, the internal EmailMessage. Internal is only accessable within the same assembly, and in most cases is the same as the access modifier private.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Dear Reader,
I have this problem - due to my absolute beginners level.
From some tools I have an xml-file as an output.
Now I want make a nice presentation of this xml-file. e.g. in a Ms-Word-Document or as and html-page, which can be displaye via inet-explorer.
I think this can be done via some xslt-transformation?
But I dont know.
Can somebody give me some hints/links how this task can be done?
Thank you for your help
|
|
|
|
|
What do you mean by 'nice presentation'? You can view a XML file in your browser as is. If you don't want to have it look like a typical XML file, you will need to parse it and display it the way you want.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Hallo,
What I want to do is e.g. to format the raw xml-file to a nice looking html page with chapters, subchapters, colored chapternames,.. and all that nice stuff.
Or I want to format the raw-xml-data to ms-word-document
Thank you for your reply
|
|
|
|