|
0x3c0 wrote: Tip 2: Use plain English
That's a bit rude. The poster is obviously someone whose first language is not English, but has still tried hard to make their question clear.
|
|
|
|
|
I was a touch cranky last night to be honest. I'm not too happy with the way that sounds, and I agree it was rude. Edited
|
|
|
|
|
It's a trap we can all fall into quite easily - I'm as guilty as anyone. I make it a rule now always to use the preview button on my replies and read through a couple of times before I post. And then I re-read it after posting just in case.
The good thing about these forums is that not only do we police the spammers, but also each other.
|
|
|
|
|
Hi,
you are right, all painting should be done in the Paint handler.
however if your drawing isn't to be constant, you should call Invalidate() when a change is needed.
So here, add CheckedChanged handlers to your checkboxes and have them call Invalidate; you may even share such a handler for many Controls.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
thanx..i got it and iots working now..
|
|
|
|
|
you're welcome.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
iwant to write CSMA/CD with c#
|
|
|
|
|
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
No need to ask. Go ahead, please.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Gosh - it's been a long time since anybody mentioned Carrier Sense Multiple Access with Collision Detection. Good on you. What's your question?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
anooshe wrote: iwant to write CSMA/CD with c#
For what purpose?
|
|
|
|
|
What made you feel you needed to ask for permission ? If you ever have an actual programming question, I suggest you read the guide on how to ask questions, first.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi, I'm making a Bingo Generator for a assignment, but it generates the last number, then should you click the button again it crashes, also crashing VS2010 so I don't get a error either. here's the button code:
var lineCount = 1;
using (var reader = File.OpenText(@"saved.bingo"))
{
while (reader.ReadLine() != null)
{
lineCount++;
}
}
TextWriter saveCalled = new StreamWriter("saved.bingo");
saveCalled.Write(called.Text);
saveCalled.Close();
TextReader loadSaved = new StreamReader("saved.bingo");
string saved = loadSaved.ReadToEnd();
loadSaved.Close();
randomGenerated.generate();
TextReader nextBingo = new StreamReader("bingoNext.bingo");
string bingoNum = nextBingo.ReadToEnd();
nextBingo.Close();
bingoNum = bingoNum.Trim();
if (saved.Contains(bingoNum) == true)
{
randomGenerated.generate();
}
else
{
TextReader tr = new StreamReader("saved.bingo");
string saveNm = tr.ReadToEnd();
tr.Close();
int saveNum = saveNm.Count();
if (saveNum >= 15)
{
button1.Visible = false;
MessageBox.Show("Game Over.");
}
newnum.Text = bingoNum;
TextReader nextCalled = new StreamReader("calledNext.bingo");
string calledNum = nextCalled.ReadToEnd();
nextCalled.Close();
called.Text = calledNum;
}
and the generator code:
namespace openBingo
{
public class randomGenerated
{
public static void generate()
{
System.Random linegrab = new System.Random(DateTime.Now.Millisecond);
TextReader numRead = new StreamReader("numbers.bingo");
ArrayList lines = new ArrayList();
string line;
while ((line = numRead.ReadLine()) != null)
{
lines.Add(line);
}
int randomIndex = linegrab.Next(lines.Count);
string bingoNum = (lines[randomIndex]).ToString();
numRead.Close();
TextReader numbCheck = new StreamReader("saved.bingo");
string saved = numbCheck.ReadToEnd();
saved = saved.Trim();
numbCheck.Close();
if (saved.Contains(bingoNum))
{
randomGenerated.generate();
}
else
{
TextWriter saveNum = new StreamWriter("saved.bingo");
saveNum.WriteLine(bingoNum);
saveNum.Close();
string randBingo = bingoNum;
TextWriter subNum = new StreamWriter("bingoNext.bingo");
subNum.WriteLine(randBingo);
subNum.Close();
string newCalled = saved + " " + randBingo;
TextWriter subCol = new StreamWriter("calledNext.bingo");
subCol.WriteLine(newCalled);
subCol.Close();
}
}
}
}
It also gives no error on compiling either.
Thanks in advance, any more info you need to just say.
Ben.
|
|
|
|
|
Wrap the code in try/catch block and print out the exception.
Best wishes,
Navaneeth
|
|
|
|
|
Hi,
you need to figure out where things go wrong. Start by using a try-catch block, and displaying the exception, all of it. Hence use something along these lines:
try {
} catch (Exception exc) {
Console.WriteLine(exc.ToString());
}
You can do this in the button click handler, in the generate() method, etc.
Then watch the line numbers (and tell Visual to always show them, see here[^])
BTW: your program looks terrible. Many things seem less than good.
- Why are you writing and reading files all the time? Don't you trust the computer's memory?
FYI: there are File methods that read or write all text of a file.
- For random numbers, you should only have a single RNG and call Next on it, instead of creating new ones.
- generate() is recursive. Any idea what keeps it from recursing forever? (which would cause a StackOverflowException).
- and please stop abusing the var keyword, use real types instead.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hi again,
How would I store something in the computers memory?
Ben.
|
|
|
|
|
Normally you keep the data in variables as long as your app is running; and you save it to disk, if needed, when the app exits.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Haha, I do try, but sometimes i need to use the data of the variable in a diffrent button control or something, and it wont let it.
I tried settting it to something like:
public void button1
but no luck
Thanks,
Ben.
|
|
|
|
|
Ben Magee wrote: I tried settting it to something like:
public void button1
but no luckFrown
I think maybe you need to study the basics of C#.
|
|
|
|
|
Richard MacCutchan wrote: I think maybe you need to study the basics of C#.
Did some studying, I now understand I need a public class with static variables inside to store data.
Thanks for the advice (:
Ben.
|
|
|
|
|
Ben Magee wrote: I now understand I need a public class with static variables inside to store data.
I think my previous statement still stands. This is not the way to store data within classes or methods.
|
|
|
|
|
Ben Magee wrote: it generates the last number
Do you mean it goes through all the available numbers and then you try to get one more? When there aren't any more? Don't you want to reset at some point?
|
|
|
|
|
When the form loads, it generates all the numbers, and writes them to a file. When you press the button, it gets a random line from that file, and then the number on it, it then checks if the number is in a file with the numbers already called, if it isnt, it adds it to that file and then displays it.
Forgive me, I am still relatively new to C# - and I am looking up on sharing variables between classes now.
BtM.
|
|
|
|
|
Regardless of the implementation; once you've selected all the numbers, there are no more to select no matter how hard you try. You need to reset.
|
|
|
|
|
Hi all,
I have an asp.menu that is bound to a SiteMapDataSource. The web.sitemap file is built dynamically via the Session_Start method in global.asax. On each Session_Start a query is made to a table called "categories" in my database which contains all the sitemap data. This data is used to generate the web.sitemap file.
I've set a breakpoint and I actually see the web.sitemap file getting rebuilt everytime, however, even when the web.sitemap changes I see no change in the menu. It is not until I make a change to the web.config and save it that the changes to the web.sitemap are reflected in the menu. This tells me it is somehow getting cached.
Can someone please help??
Thanks!
Tim
|
|
|
|