|
Hi,
If you expose the Dictionary's value collection you will get this functionality.
Dictionary<string, Customer> dic;
ICollection<Customer> Customers {
get { return this.dic.Values; }
}
I think that's all you need as the value collection is enumerable.
Alan.
|
|
|
|
|
CodingYoshi wrote: What should I do if I want the client to be able to do this:
foreach (Customer c in this._customers)
{
c.Name = "whatever";
}
How about this?
public class CustomerCollection : IEnumerable<Customer>
{
public IEnumerator<Customer> GetEnumerator()
{
foreach(KeyValuePair<string,Customer> item in _districts)
yield return item.Value;
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
|
|
|
|
|
Thanks! That is exactly what I am looking for. I will give that a try and let you know if it works; although, it looks as it should.
CodingYoshi
Artificial Intelligence is no match for Human Stupidity.
|
|
|
|
|
could someone point out what I am doing wrong that the reportProgress method is not working.
BackgroundWorker bw = new BackgroundWorker();
public Control()
{
bw.WorkerReportsProgress = true;
bw.WorkerSupportsCancellation = true;
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
}
void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
//do updates
}
void bw_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
if ((worker.CancellationPending == true))
{
e.Cancel = true;
}
else
{
//work code removed
totalnumbersoffiles = XmlFiles.Count;
for (int filecount = 0; filecount < XmlFiles.Count; filecount++)
{
//work code removed
bw.ReportProgress(filecount);
}
}
}
|
|
|
|
|
Not sure what's wrong with your code - this sample code below works though so compare the two.
public class Test
{
private BackgroundWorker backgroundWorker;
public Test()
{
backgroundWorker = new BackgroundWorker();
backgroundWorker.WorkerReportsProgress = true;
backgroundWorker.WorkerSupportsCancellation = true;
backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
}
public void StartTest()
{
backgroundWorker.RunWorkerAsync();
}
private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
Console.WriteLine(e.ProgressPercentage);
}
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i <= 100; i++)
backgroundWorker.ReportProgress(i);
}
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
Console.WriteLine("Done");
}
}
Test t = new Test();
t.StartTest();
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Planker wrote: totalnumbersoffiles = XmlFiles.Count;
for (int filecount = 0; filecount < XmlFiles.Count; filecount++)
{
//work code removed
bw.ReportProgress(filecount);
}
This looks odd to me.
|
|
|
|
|
instead of
bw.ReportProgress(fileCount)
write
worker.ReportProgress(fileCount+1)
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Hi,
I want to change Crystal Reports Details section(Section3) height in code behind with C# or VB.NET.
Help me...
|
|
|
|
|
Hello everybody,
first I want to tell you that I don't know C# - I'm programming in VB.NET which works for most things I need. Now I have the need to extend a working C# class with a method that converts an RGB Array to its rows, which I did in VB first and had it translated to C# in order to implement.... BUT: The translation from SharpDevelop, which seemed to work fine, is not recognized by the Visual Studio compiler.
Maybe someone of you could help me find what's wrong? Here's the translation from SD:
public int[] FromArray(Array RGBArray)
{
int[] returnValue = new int[imageHeight];
for (int i = 0; i <= returnValue.Length - 1; i++)
{
for (int j = 0; j <= imageWidth; j++)
{
returnValue[i] = SetRow(i, RGBArray(j));
}
}
return returnValue;
}
The compiler tells me "RGBArray is a Variable but is used like a Method"
Thank you for helping out,
Mick
|
|
|
|
|
Michael Schäuble wrote: returnValue[i] = SetRow(i, RGBArray(j));
The code spinet might should be:
<br />
returnValue[i] = SetRow(i, RGBArray.GetValue(i,j));<br />
RGBArray(j) is VB.NET style indexer,not C#.System.Array type doesn't have any indexers defined so to get a value an position j you shoud use GetValue method and to set value just call System.Array.SetValue(object,params[] indexes) method.
[EDIT]
Are you sure that j index is not outside of RGBArray?
Life is a stage and we are all actors!
modified on Tuesday, August 25, 2009 4:01 PM
|
|
|
|
|
Thank you for the support, Hristo!
You were right regarding 'other problems' in the code... I changed it to
public int[] FromArray(Array RGBArray)
{
int[] returnValue = new int[imageWidth];
for (int i = 0; i < imageHeight; i++)
{
for (int j = 0; j < imageWidth; j++)
{
returnValue[j] = (int) RGBArray.GetValue(j);
}
SetRow(i, returnValue);
}
return returnValue;
}
Would you agree with that?
modified on Tuesday, August 25, 2009 4:15 PM
|
|
|
|
|
In order to avoid confusing with array indexing you would better use i < imageHeight instead of i <= imageHeight -1 .
Life is a stage and we are all actors!
|
|
|
|
|
Just had corrected that obviously while you were posting.
Thanks for your help and have a nice evening!
|
|
|
|
|
Always glad to help to someone!
Life is a stage and we are all actors!
|
|
|
|
|
Hi,
I am working with C# .net. I have created a software application and the application works fine. But I am not able to launch my product as the .net framework is creating a problem. My application size is just 1MB but the framework makes it heavy. No user would like to download 30 MB from internet to run the application.
I don't understand Microsoft says the VS is framework independent then why a C# application installer needs framework.
Is there a way to remove the dependency?
Looking forward to hear a solution.
Thanks in advance 
|
|
|
|
|
No, Target machine must have DNF else application wont launch. And these days almost every pc have DNF installed and even if not then your application must enough useful and attractive to force user to install DNF. But if you're selling your app then you can provide a setup of DNF alongwith the installation disk.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Waheed Ur Rehman wrote: I don't understand Microsoft says the VS is framework independent then why a C# application installer needs framework.
Managed code is not dependant of VC redists so this avoids the DLL hell.It could be ported to another OS like Linux or MAC and with almost zero touch.So .NET code is much more safer and easy to deploy than unmanaged C/C++ code.NET runtime by default is part of Vista ,Windows 7 and Windows Server System(2003,2008) and XP soon will be marked as depricated,so you needn't to worry about .NET dependencies.
Life is a stage and we are all actors!
|
|
|
|
|
Is there no solution to remove DNF 2.0 from the application. The issue is the resulting size of the application. If I embed DNF or make the user to download and install from the web the application size increases more than 20 times of the actual size of the application.
|
|
|
|
|
No. No more than you can write an MFC/VB6 application that doesn't depend on the MFC/VB6 rumtime being installed.
There is software that will compile the needed parts of the framework that are written in .net into your executable and package up the parts of the framework that are written in C++ so that the framework doesn't need to be installed. The result will be several dozen megs in size, and is probably not worth it unless you're targetting the 3.0/3.5 frameworks which are several hundred megs in size. The tools to do this also cost upwards of $1k.
Any user running a new version of windows (Vista or Later) will have 2.0 framework. IIRC w7 comes with the 3.5 framework. Any user who runs windows update in automatic mode and is running win2k or later will have the 2.0 framework, if running XP or later the 3.5 framework. That's probably >99% of windows PCs on the market. To target the rest your choices are to make them DLing a framework/runtime, or rewrite your app in pure win32 C code which calls the win32 API directly.
The latest nation. Procrastination.
|
|
|
|
|
I've set MaximizedBounds when Form's state is Maximized but that doesn't effect the form at all. I tried to set ClientSize, Size, Bounds... but nothing works. I've got a working way that is
this.WindowState = FormWindowState.Normal;
this.WindowState = FormWindowState.Maximized;
but thats raising some not required custom events and form flicks...any better way you guys know ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I'm not sure what you're trying to accomplish or what the problem is.
If you don't want the form to be Invalidated when resized then set it's ResizeRedraw property to false - you can then use a ResizeEnd event handler to determine if you need to repaint based on your requirements and call Invalidate directly.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I want that when user maximize the form then it should not be in full desktop plus user can set its location when form maximize. I found MaximizedBounds, that works good as I needed but it always have to Maximize again not like just update the bounds.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi,
I'm trying to capture incoming data from my modem.
I tried using SerialPort but all I get are the modem commands (RING, ATA, CONNECT, etc.) and not the actual data.
How can I get the actual data?
Thank you.
|
|
|
|
|
|
I should mention that I am using my Nokia phone as a modem.
I read that page already, and I tried the ATO command to go to data mode but it doesn't work.
Thanks.
|
|
|
|