|
Good afternoon OriginalGriff
Thank you for your Help. Your solution is great. i have what has been posted before. but i will still look into it
Thank you
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
ArrayList is too old and try to avoid unless you are on .NET 1.1.
Method 1
list.Sort();
int i = 0;
while (i < list.Count - 1)
{
if ((int)list[i] == (int)list[i + 1])
list.RemoveAt(i);
else
++i;
} Method 2
ArrayList target = new ArrayList(list.ToArray().Distinct().ToArray()); This works only when you have System.Linq namespace imported.
If you use .NET 3.5, use HashSet(T) class. It will not allow duplicate entries to be created. For .NET 2.0 or later, use List(T) other than ArrayList .
|
|
|
|
|
Good Afternoon N a v a n e e t h
The Duplicates are Created Intentional. My Client changed the Requirement. i was displaying a something like this
Staff Cycle
=============
James |4
Andrew |3
James |2
James |12
James |33
Cole |23
Daniel |56
This was Displayed in a Grid, so my Client want those with same name Displayed as a String. Now i wanted to Loop on the Grid on client side and look for the "James's" that appears more than once and put them in Arraylist or HashSet(T) after that and Display it like this
Staff Cycle
==================
Andrew |3
James |4,2,12,33
Cole |23
Daniel |56
Those that appears once , can remain with their single Value.
Thank you for your Help
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
A good approach is to use a hash table of List<int>, indexed by strings.
For each staff name, if it's not in the hash table, add it with a new List<int> containing the single cycle number.
If the staff name IS in the hash table, just add the cycle number to the existing List<int> associated with the name. Then to display the result, for each name in the hash table, write the name following by every cycle number in the corresponding list.
This approach only requires one pass through the data, and doesn't require sorting. The running time is O(n).
|
|
|
|
|
Thanks for your Advice. i have implemented the hashsets and they work like charm
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
You should take "C#" out of your sig until you learn it.
This has been asked/answered at least twice before. It's homework, isn't it?
"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
|
|
|
|
|
Good Afternoon Mr Simmons
I Admire your work i must say.
To Answer your question, this is not a homework, when you say this has been asked twice , Am sorry i have not come across it and i certainly goggled for it before i posted.
Thank you sir for your comment
Vuyiswa Maseko
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
If you don't want to have duplicates, I suggest using a System.Collection.Generic.HashSet
If you do want duplicates, but want to know about them, you may want to wrap something around a Dictionary and have the value of the Dictionary be the number of times the key was "added".
What exactly do you want?
|
|
|
|
|
Thanks for your comment. i have already implemented them.
Thanks
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Dear,
i published my project. it creates a setup.exe file into published folder.
when i run this setup it installs the project and create a shortcut into start-Program-project->prj.exe
can any one tell me where i found the installed file in my pc?
and how i set the path for this at the time of installation?
|
|
|
|
|
ddravin2000 wrote: can any one tell me where i found the installed file in my pc?
Right Click on Exe > Properties > Click on "Find Target " Button.
You will get the application Folder Location
ddravin2000 wrote: and how i set the path for this at the time of installation?
Yes, you can set the Installation Path.
In Setup Project
1. Select "Application Folder "
2. Go To application Folder Property Windows
3. Change the DefaultLocation Property
Default Location will specify the application install location on target computer.
by default it is [ProgramFilesFolder][Manufacturer]\[ProductName]
You can configure it
Hope this will helps you.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi
my question is that how to insert relational data with tableAdapter. for example we have 2 tables:
Orders (Parent Table)
OrderDetails (Child Table)
now, we want to insert new Order and some OrderDetails record in Relational mode :
Insert new Order & it's OrderDetails together
Order1
OrderDetails1
OrderDetails2
OrderDetails3
Insert Operation ...
as u can see in my scenario, the OrderDetails to be inserted is DataTable, not a single record. i found this article, but indeed, my problem was no solved Because :
1. it's implement by DataAdapter and i'm using TableAdapter. i think TableAdapter has a built in functionality to do this.
2. it's a single child row, wheras in my scenario the child is DataTable.
any Help ?
Thanks
|
|
|
|
|
Hi,
I am binding data to the Combobox from the database using the DataSource,DisplayMember and ValueMember.
I want to display a default text named --Select-- at index 0 in the Combobox, apart from the values in the database. How do I achieve this? I am using DataSet.
Thanks in Advance.
|
|
|
|
|
You can add manually by using ListItem.
Create a ListItem with a corresponding value then insert it into the existing Items of the combo box..
You should do this after databindin event.
|
|
|
|
|
I do this all the time, so much so that I create a method the inserts a row at position 0 in the data table. Create a new row based on the table, populate it (relevant fields only) with your default value and use table.rows.insert.
public static DataTable TableAddRow0(DataTable oTable, int iLabelCol, string sLabel)<br />
{<br />
try<br />
{<br />
DataRow oRow = oTable.NewRow();<br />
if (oTable.Columns.Count > 1)<br />
{<br />
oRow[0] = 0;<br />
oRow[iLabelCol] = sLabel;<br />
}<br />
else<br />
oRow[0] = sLabel;<br />
<br />
oTable.Rows.InsertAt(oRow, 0);<br />
return oTable;<br />
}<br />
catch (Exception)<br />
{ throw; }<br />
}
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I am using Visual Studio 2008, i am writing a small code for Net Compact Framework. I use Windows Mobile Emulator. Now my code is in Directory "c:\Works\UI\MyProj". Now when i use following command
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
it returns \Program File\MyProj instead of "c:\Works\UI\MyProj". I want to access another folder in the same directory called Images. I use something like this
MyImage = new Bitmap(path + @"\Images\myImage.bmp");
but when i try to execute the aove statement it returns the following error
Could not find a part of the path '\Program Files\MyProj\Images\myImage.bmp'.
How do i access the Images folder in my project directory
Regards
Hiten Parmar
|
|
|
|
|
Check out the System.IO.Path class. Specifically, you may find Path.GetFullPath() and Path.Combine() useful.
If your image is located in a subdirectory in the directory of your app, you could just do
MyImage = new Bitmap("Images\myImage.bmp"); . You don't need the full path there.
|
|
|
|
|
Hi everyone,
Iv'e created small application that sends files to a server using ftp.
I got 2 network adapters on my machine.
when i monitoring the communication i see that each time a different network adapter is sending the package.
My question is can i select which network adapter to use in the code level (if yes how) or it should be a netwok setting.
thanks in advanced
|
|
|
|
|
Hi
I had an application of BHO. It had been developed using visual Studio 2005. Actually, it main aim is to read the text of HTML page and write that into a text file. I had checked this on IE6 and IE7 in various PC's. before that I had installed .Net Framework 2.0 also. If I register that dll in some pc's it works perfectly on both IE6 and IE7. but on some PC's it doesn't write the html page's text into a file? what may be the problem?
How on earth can I figure out why there is a difference? I have compared tools>internet options>advanced. The settings on both computers are identical. They also both have all 4 security zones at the same level and they both have the same general settings.
modified on Monday, April 20, 2009 1:24 AM
|
|
|
|
|
hello
VBA calling C# code anyone? I'm looking for an article/tutorial.
Thanks
dev
|
|
|
|
|
|
Thanks - seen better ways to do this (than wrapping it in COM/ATL server) now with Excel 2008?
I remember I done ATL server way back don't like this. You've got to marshall data into BSTR and all that (even thrown out the book now), just don't like the mechanism.
For example, this looks about right: http://www.c-sharpcorner.com/UploadFile/jodonnell/Excel2003fromCSharp12022005021735AM/Excel2003fromCSharp.aspx[^]
This article shows you how to generate Excel doc with C#, setting cell value via Excel object model and all. But still to call say C# component/dll from Excel VBA code... seems like COM is the only way?
But
dev
|
|
|
|
|
COM isn't ideal, but I don't know any other options unfortunatly. The example you posted seems to be about replacing VBA in Excell with C#. I doubt that you're looking for Excell-automation-article's, so that's not going to help either.
Seems COM is the way to go, sorry
I are troll
|
|
|
|
|
haha - COM is still alive afterall.
dev
|
|
|
|
|
Eddy Vluggen wrote: COM isn't ideal, but I don't know any other options unfortunatly.
Neither do I, and I've looked in the past. On the plus side as long as you keep your types within the allowed values on the .net side (this doesn't cause any sort of compile time error, the method's just not exposed in COM) all you really have to do is to tell the compiler to make it a com class. From proof of concept testing, it's reasonably painless.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|