|
I think that you don't want to do what you are asking for at all. I think that you want to create the ArrayList once, and use it in the recursive function.
Create the ArrayList before you call the recursive function, and pass the reference to the ArrayList as a parameter:
static void Permute(int[] a, int start, int finish, ArrayList results)) {
results.Add(a);
if (start != finish) {
Permute(a, start + 1, finish, results);
}
}
---
b { font-weight: normal; }
|
|
|
|
|
Hello
Again?!! Why do you insist on making it in a recursive call?? One line of code is enough:
ArrayList MyArrayList = new ArrayList(a);
If you insist, you can check if the ArrayList is already initialized before reinitializing it:
ArrayList alist;
static ArrayList Permute(int[] a, int start, int finish)
{
if(alist.Count == 0)
alist = new ArrayList()
alist.Add(1);
alist.Add(2);
if(start != finish)
Permute(a, start+1, finish)
return alist;
}
but I'm sure there is a much better way of doing whatever you are trying to do!! Please post more details about what you are trying to do, perhaps we code suggest a better approach.
Regards
|
|
|
|
|
Hey all,
I am trying to create a windows.forms.control object that has the resize function like a normal windows.form object (real-time windows.form size change displayed). Can anyone help me with it? I cannot find a way to do it, been searching for awhile and cannot find any way to do so.
Thanks in advance!
Tom
|
|
|
|
|
Hello
Well, I guess you have to do it manually!! Have a lok at this article[^].
Regards
|
|
|
|
|
Hey Nader
Thanks for your help!! I couldnt find it before!! Thx Thx
Tom
|
|
|
|
|
I have a DataGrid. I want to enable a "commit" button once the user modifies any column in the row. When user leaves that column (CurrentCellChanged event fires) -- I check the underlying DataSet for changes via DataSet.HasChanges(). If user has clicked anywhere outside of original row - still in grid or otherwise --- no problem. Problem is if user simply stays within the original row --- no changes have been detected by the dataset yet.
I have done some searching and found others with this problem, but haven't found a solution --- mostly frustrated comments as to why this appears to be so difficult. Anyone know how to detect that the datagrid has a change that is about to be committed to the dataset as soon as the user leaves the current row??
Thanks in advance.
John
|
|
|
|
|
Hello
The problem is -as I got from your post- that you want to detect changes made to the DatagridView -or was that DataGrid only?- when the user changes the content of one cell and moves to another cell within the same row, right??
Well, DatagridViews don't signal changes until you commit the current row to the current transaction. That means that until you actually leave the row, you still have a chance to cancel your changes. The unit of editting is the row, not the cell. So, if you want to narrow the spectrum of changes detection, you have to do it manually by handling events like CellEndEdit if you use .Net 2.0 framework.
Regards
|
|
|
|
|
Thanks Nader.
You've confirmed what I thought. And no, I'm using 2003 Vis Studio with 1.1, so don't seem to find the CellEndEdit event. I guess I can instruct users to do an extra click outside the row to enable the "commit" button. Not really sure why this wasn't as obvious to MS earlier but if I understand correctly, they've provided a solution in the newer version, but still with a little more intervention than maybe one should have to make.
It seems so natural that as soon as you make any change, the user should immediately have the ability to save the change -- i.e., shouldn't be told "click here so you can click someplace else".
Thanks again for your info.
John
|
|
|
|
|
"Hello Dear brother please read u'r mail and reply me a soon as possible. But u must reply. I am waiting. Have u read the mail?"
Syed Shahid Hussain
|
|
|
|
|
I've got a problem with this code in C#:
Controls[id + "gbR" + r].Controls[id + "rtbRunda" + r + "ABin"].ReadOnly = p;
The first Control is GroupBox, the second is RichTextBox, 'id' and 'r' is an integer. I want to change the ReadOnly property, but compilator throws na error: "'System.Windows.Forms.Control' does not contain a definition for 'ReadOnly'"
What should I do? I've tried some casting, but without success.
Thanx for any help!
|
|
|
|
|
Hello
You must cast your control first from Control type to RichTextBox type:
Control MyControl = Controls[id + "gbR" + r].Controls[id + "rtbRunda" + r + "ABin"];
if(MyControl is RichTextBox)
{
((RichTextBox)MyControl).ReadOnly = p;
}
else
{
}
Regards
|
|
|
|
|
Yes, it needs two pairs of parentheses, when casting, oh my...
((RichTextBox)Controls[id + "gbR" + r].Controls[id + "rtbRunda" + r + "ABin"]).ReadOnly = p;
Thanx for advice!
|
|
|
|
|
Hi Nader
Just a small nitpick, but the code you posted requires a double cast: one cast to check if the control is a RichTextBox, then another cast to cast it to a RichTextBox.
Here's a superior way to do it:
RichTextBox richTextBoxControl = myControl as RichTextBox;
if(richTextBoxControl != null)
{
richTextBoxControl.Readonly = p;
}
else
{
}
|
|
|
|
|
I have a remoting app that works fine when executed from a local hard drive, but will give "This assembly does not allow partially trusted callers" exception when executed from a network drive. The remoting app is used for transfering files. The code for server, shared assembly, and client:
<br />
<br />
using System;<br />
using System.Collections;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Runtime.Remoting;<br />
using System.Runtime.Remoting.Channels;<br />
using System.Runtime.Remoting.Channels.Http;<br />
using System.IO;<br />
<br />
namespace RemotingTest<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
IDictionary properties = new Hashtable();<br />
<br />
SoapClientFormatterSinkProvider clientSinkProvider = new SoapClientFormatterSinkProvider();<br />
SoapServerFormatterSinkProvider serverSinkProvider = new SoapServerFormatterSinkProvider();<br />
<br />
serverSinkProvider.TypeFilterLevel =<br />
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;<br />
<br />
properties["name"] = "";<br />
properties["port"] = 0;<br />
properties["typeFilterLevel"] = "Full";<br />
<br />
HttpChannel commChannel = new HttpChannel(properties, clientSinkProvider, serverSinkProvider);<br />
<br />
ChannelServices.RegisterChannel(commChannel, false);<br />
<br />
RemotingConfiguration.RegisterWellKnownClientType(<br />
typeof(ServerInterface),<br />
"http://igor.no-ip.ca:1024/Server");
<br />
ServerInterface server = new ServerInterface();<br />
<br />
string text = "";<br />
<br />
while((text = Console.ReadLine()) != "Quit")<br />
{<br />
Console.WriteLine(server.ShowText("testing string"));<br />
Console.WriteLine(server.ShowFileInfo(text).Name);<br />
}<br />
<br />
Console.Read();<br />
}<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.IO;<br />
<br />
namespace RemotingTest<br />
{<br />
public class ServerInterface: MarshalByRefObject<br />
{<br />
public FileInfo ShowFileInfo(string filename)<br />
{<br />
Console.WriteLine("Filename " + filename + " requested");<br />
<br />
return new FileInfo(filename);<br />
}<br />
<br />
public string ShowText(string text)<br />
{<br />
Console.WriteLine(text);<br />
<br />
return "\"" + text + "\" show on the server.";<br />
}<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
using System;<br />
using System.Collections;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Runtime.Remoting;<br />
using System.Runtime.Remoting.Channels;<br />
using System.Runtime.Remoting.Channels.Http;<br />
<br />
namespace RemotingTest<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
IDictionary properties = new Hashtable();<br />
<br />
SoapServerFormatterSinkProvider serverSinkProvider = new SoapServerFormatterSinkProvider();<br />
<br />
serverSinkProvider.TypeFilterLevel =<br />
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;<br />
<br />
properties["name"] = "";<br />
properties["port"] = 1024;<br />
properties["typeFilterLevel"] = "Full";<br />
properties["machineName"] = "igor.no-ip.ca";
<br />
HttpChannel commChannel = new HttpChannel(properties, null, serverSinkProvider);<br />
<br />
ChannelServices.RegisterChannel(commChannel, false);<br />
<br />
RemotingConfiguration.RegisterWellKnownServiceType(<br />
typeof(ServerInterface),<br />
"Server", WellKnownObjectMode.SingleCall);<br />
<br />
Console.Read();<br />
}<br />
}<br />
}<br />
Please help.
|
|
|
|
|
If you want your application to allow partially trusted callers, go into AssemblyInfo.cs (typically auto-generated in the Properties folder of your solution) and add the following line:
[assembly: System.Security.AllowPartiallyTrustedCallers]
|
|
|
|
|
hey all, i'm sure this is a dumb question:
but...
How do I create / access / modify properties that are available to all classes of my solution?
iow, I have a main namespace, and multiple forms that are all separate classes/.dlls.
I need to beable to access the properties of the main form throughout the rest of the application, regardless of whether or not the sub classes are instaniated yet.
So..
ClassA(mainFrm) calls ClassB(subUsrCrtl1) which does some work then calls ClassC(subUsrCtrl2) which displays extended info from the work done in ClassB. Then ClassA can call ClassD(E,F,G,etc)(subUsrCrtl3(,4,5,6,etc)) who make other information available based on the work done in ClassB. Many of the classes that are available are not used everytime, so they aren't instantiated yet.
I need to beable to retrieve data from the work that is completed in ClassB and use that data throughout all available classes.
Currently I'm only able to access that data in a class to class relationship where I end up with either old or null values becuase i'm having to instantiate the required class again from the current class...(i.e. ClassA calls ClassD, ClassD needs data from ClassB, so ClassD instantiates new ClassB but that returns null data...)
hope this make sense, cause i'm lost....
ehlp.... wait i can't even spell help...
string Beautiful;
Beautiful = "ignorant";
label1.Text = "The world is full of " + Beautiful +" people.";
Why is common sense such an un-common comodity?
|
|
|
|
|
If you want values to be used across different instances it is better to make those properties as static members of the class and access them from the class scope.
A better approach would be to take out the information you want to make available across the application and put them into one class. Make a static instance of that class to use across the other classes.
--------------------------------------------------
|
|
|
|
|
Ok, I know that this is something stupid... but I'm trying to write my first project in C#. Unfortunately I have only VS 2005 (my friend is using Express Ed).
The lab machine that project must work on have .NET 1.1
Is there any way to set VS to compile my project with .NET 1.1
I want to be sure that what I'm using will be working on machine with .NET 1.1 and without .NET 2.0
Please give some help about that, If this is stupis question then fill free to write that (along with explanation).
I need to finish the project fast... thats way I can't afford to search this information or to actually test my app on machine with .NET 1.1
Thanks for any help
best regards,
Slawek
PS. link to MSDN page will be great
|
|
|
|
|
|
http://msdn.microsoft.com/vstudio/downloads/tools/msbee/default.aspx
string Beautiful;
Beautiful = "ignorant";
label1.Text = "The world is full of " + Beautiful +" people.";
Why is common sense such an un-common comodity?
|
|
|
|
|
Im trying to read out an xml file which has several files inside like this:
<File Name="Luc.JPG" Src="50000000.000"><br />
- <MetaInfo><br />
<MetaKey Name="vti_modifiedby" Value="SR|SCALEHOSTING\scale" /><br />
<MetaKey Name="vti_filesize" Value="IR|384548" /><br />
<MetaKey Name="vti_timecreated" Value="TR|30 Jun 2006 16:30:19 -0000" /><br />
<MetaKey Name="vti_lastheight" Value="IX|1200" /><br />
<MetaKey Name="vti_timelastmodified" Value="TR|30 Jun 2006 16:30:19 -0000" /><br />
<MetaKey Name="vti_lastwidth" Value="IX|1600" /><br />
<MetaKey Name="vti_author" Value="SR|SCALEHOSTING\scale" /><br />
<MetaKey Name="vti_sourcecontrolversion" Value="SR|V1" /><br />
<MetaKey Name="vti_sourcecontrolcookie" Value="SR|fp_internal" /><br />
</MetaInfo><br />
</File>
I have tryed several examples but i simply cant figure it out,
any help appriciated.
Scale.
|
|
|
|
|
You are going to have to be more specific as to what your problem is
only two letters away from being an asset
|
|
|
|
|
Ill try i have a file manifest.xml,
its filled with file entry's an example of a file entry:
<file name="Luc.JPG" src="50000000.000">
- <metainfo>
<metakey name="vti_modifiedby" value="SR|SCALEHOSTING\scale">
<metakey name="vti_filesize" value="IR|384548">
<metakey name="vti_timecreated" value="TR|30 Jun 2006 16:30:19 -0000">
<metakey name="vti_lastheight" value="IX|1200">
<metakey name="vti_timelastmodified" value="TR|30 Jun 2006 16:30:19 -0000">
<metakey name="vti_lastwidth" value="IX|1600">
<metakey name="vti_author" value="SR|SCALEHOSTING\scale">
<metakey name="vti_sourcecontrolversion" value="SR|V1">
<metakey name="vti_sourcecontrolcookie" value="SR|fp_internal">
On disk i have a 500000000.000 file which i need to rename into luc.jpg (the rest aint that important).
But i cant figure out how to read out all the specif lines with
|
|
|
|
|
Scalee wrote: I hope this is beter explained
No
only two letters away from being an asset
|
|
|
|
|
The most simple way i can put it would be:
I have an XML file with allot of lines:
<file name="Luc.JPG" src="50000000.000"> but difference source and file names.
Also allot of other crap.
Now i need to read out that XML file and get all lines that start with
|
|
|
|