|
Ooooo, that's below the belt
return 5;
|
|
|
|
|
At work I'd do what Pete suggests: break the problem down into smaller tasks, and break those down further. At some point I'd have a strategy, so I'd start coding.
At home I'd just start coding, get about 6 hours into the problem, then wish I'd done what I would have done, had I been at work.
At university I'd have done what Pete suggests, but I'd make sure it satisfies the lecturer's [programming] peccadilloes, and made it properly documented .
Do you have a Neural Network Yet?
|
|
|
|
|
More to the point - Why would you?
You surely have little experience in programming based on the fact you have posted a question such as this.
If this is an assignment of some sort then you should complain that you have not been taught enough to complete this assignment (unless you skipped those lessons?), or maybe its the first task of your new programming job (which you shouldn't have) - so then I recommend you cough up about your inexperience sooner rather than later
return 5;
|
|
|
|
|
First you have to learn the technique, independently of any programming language. These are two radically different ways of approximating functions, and if it's possible to simulate the series solutions with a neural net, SOMEONE has described this technique SOMEWHERE. Google is your friend (as least for finding information).
|
|
|
|
|
Dear Friends,
I have a datagridview in which there is parent child relationship in rows. I want that If a parent row is checked in the datagrid and any child node corresponding to it is checked then if the user tries to uncheck the Parent Row then the Parent row shouldn't gets uncheck and remains checked.
I have tried to write the code for the same on CELLCONTENTCLICK event and on the CELLVALUECHANGEDEVENT but all in vain
Any kind of help will be appreciable.
Thanks
Varun Sareen (Dot Net Developer)
modified on Wednesday, December 22, 2010 2:02 AM
|
|
|
|
|
Varun Sareen wrote: I have a datagridview in which there is parent child relationship in rows. If a parent row is checked in the datagrid and any child node corresponding to it is checked then if the user tries to uncheck the Parent Row then that row doesn't gets uncheck and
it again gets checked on itself.
Just keep toggling, I mean
If(checked)
uncheck;
else
check;
|
|
|
|
|
Thanks Hiren, for an immediate reply but i am sorry to say that I actually asked the wrong question (there was a little grammar mistake that made the question meaning other way around).
Now I have corrected the question so now if you could look into it and provide me with some answer then that would be appreciable.
Thanks
Varun Sareen (Dot Net Developer)
modified on Wednesday, December 22, 2010 4:21 AM
|
|
|
|
|
No clue off the top of my head how to do it, but...
Look for some treeview examples that have tri-state checkboxes (they do pretty much what you want to do in your gridview...sort of).
You may get some ideas looking at how they do it. (It's going to wind up being a matter of getting all the children and seeing if they're checked before dealing with the parent)
|
|
|
|
|
I've got a bit of code that works nicely, but it's really ugly and it offends my sense of style. To wit,
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private static string Header = @"^(D|""D|T|S|I|E|""Z)";
private static string Blank = @"^$";
private static string Total = @"^""To";
private static string Sum = @"^""\d\d/\d\d/\d\d\d\d"","""",";
private static string NewData = @"^""\d\d/\d\d/\d\d\d\d"",";
private static string Data = @"^"""",""\w";
private string[] SourceFiles = new string[100];
private int FileCount;
public string WkgDirectory;
public DataSet MeterReads = new DataSet();
public Regex RgxHeader = new Regex(Header);
public Regex RgxData = new Regex(Data);
public Regex RgxNewData = new Regex(NewData);
public Regex RgxTotal = new Regex(Total);
public Regex RgxBlank = new Regex(Blank);
public Regex RgxSum = new Regex(Sum);
public Queue<string> OutQueue = new Queue<string>();
private int Classify(string s)
{
Match m;
m= RgxHeader.Match(s);
if (m.Success) return 0;
m= RgxBlank.Match(s);
if (m.Success) return 1;
m= RgxTotal.Match(s);
if (m.Success) return 2;
m= RgxSum.Match(s);
if (m.Success) return 3;
m= RgxData.Match(s);
if (m.Success) return 4;
m= RgxNewData.Match(s);
if (m.Success) return 5;
return 99;
}
Mind you, I was fairly drunk when I wrote it, but it works perfectly and I hesitate to change it. But it's still ugly.
I don't like having variables stuck in the Form when they're only used in one method. I'd slide all the declarations down into the Classify() method, but I'm afraid that this would cause them to be created and destroyed every time the method was called. That could really bog things down. My understanding of static methods is a bit fuzzy, but I suspect that if I put all the declarations in the method, and make the method static, this might eliminate the problem. Is that true, or should I just hide all the ugly bits in a region and get along with finishing the app?
Or is there a better way?
Will Rogers never met me.
|
|
|
|
|
Break it out into a library class. Possibly use a classification enumeration and a Dictionary<RegEx,Classification> -- dang, you could write a RegExMatchOmatic<Classification>.
Whaddaya think? Is tomorrow a good day to drive to L.A.?
|
|
|
|
|
PIEBALDconsult wrote: Is tomorrow a good day to drive to L.A.?
No. If there's any way that you can delay the trip a day, do so. Tonight and tomorrow they're supposed to get the worst of it, but by Thursday they roads should be drained, at least. Where are you heading? By what route? The Grapevine (I-5) will be closed by morning, I'm sure, if the temperature drops. And I-15 at Cajon Pass (North of San Bernardino) always closes when the snow starts to fall below 5,000 feet.
Will Rogers never met me.
|
|
|
|
|
We're heading straight west on the 10 to the 5. My in-laws are just off the 5 near Griffith Park so there's only about a mile of surface streets involved. I just hope their hill doesn't slide.
We've lived in SoCal during some big storms and remember the mayhem. We could hold off until tomorrow, but we don't see much point... although it would be good to spend the night in Laughlin...
|
|
|
|
|
PIEBALDconsult wrote: it would be good to spend the night in Laughlin...
Hehehe... That might be risky, too. They're calling for tremendous rains here, as well. But the fact is, it's 8:00 and we still haven't seen anything but a light, sporadic drizzle. I did get new wipers, though, just in case.
Will Rogers never met me.
|
|
|
|
|
We made it safely. We did stop a couple of times during the worst downpours because visibility was very poor.
|
|
|
|
|
Enjoy your holiday, then! The rain is supposed to stop tomorrow, then sunny to partly cloudy the rest of the week(end).
Will Rogers never met me.
|
|
|
|
|
There is a static Regex.IsMatch(input,pattern) method which could fit the bill, and avoid all class members. I am not sure how it would compare performance wise, I don't expect a significant difference but could be wrong.
|
|
|
|
|
Well, for a start, if you want to continue using this, make Classify static. There's no real reason for it to be an instance method. Then, I would consider creating a Dictionary of the patterns. You could rewrite this as:
private enum DataMatches
{
Header = 0,
Blank = 1,
Total = 2,
Sum = 3,
NewData = 4,
Data = 5,
Unmatched = 99
}
private static void SetupRegex()
{
if (dataPatterns != null && dataPatterns.Count > 0) return;
dataPatterns = new Dictionary<string, DataMatches>();
dataPatterns.Add(@"^(D|""D|T|S|I|E|""Z)", DataMatches.Header);
dataPatterns.Add(@"^$", DataMatches.Blank);
dataPatterns.Add(@"^""To", DataMatches.Total);
dataPatterns.Add(@"^""\d\d/\d\d/\d\d\d\d"","""",", DataMatches.Sum);
dataPatterns.Add(@"^""\d\d/\d\d/\d\d\d\d"",", DataMatches.NewData);
dataPatterns.Add(@"^"""",""\w", DataMatches.Data);
}
private static DataMatches Classify(string s)
{
SetupRegex();
foreach (KeyValuePair<string, DataMatches> kvp in dataPatterns)
{
if (Regex.IsMatch(kvp.Key)) return kvp.Value;
}
return DataMatches.Unmatched;
}
|
|
|
|
|
Yes, that's what I'd do, but I'd wrap it in a class and have an Attribute to associate the RegEx with the enum member.
private enum DataMatches
{
[RegExAttribute("pattern",Options=options)]
Header = 0
,
|
|
|
|
|
This always returns the same hashcode:
static Regex myRegex = new Regex("");
public static int Bar()
{
return myRegex.GetHashCode();
}
This doesn't,
public static int Foo()
{
Regex myRegex = new Regex("");
return myRegex.GetHashCode();
}
So the object is being created and destroyed at each call, which is expected I suppose. Whether this is heavy enough to have impact on the performance significantly is another matter. A suck-it-and-see approach is best in these circumstances (assuming performance is an issue in the first place, otherwise I'd just go for the cleanest code).
|
|
|
|
|
That is correct, and as expected. Of course in VB you could make the variable static and it wouldn't change.
|
|
|
|
|
|
You're in the wrong forum since C# cannot make any use of ATL.
You're looking for the Visual C++ forum, right above the C# forum in the left-side navigation of this page.
|
|
|
|
|
|
I'd like to be able to see the instant a legal banner appears in a remote desktop window and send an enter key to it to dismiss it during logon.
Does anyone know how to read the windows of a remote desktop window? Are they encrypted?
|
|
|
|
|
I'm pretty sure that what I'd try won't work, but I can't try it until I get back to work on Tuesday.
|
|
|
|