|
OK
i try now in my VS2005, and this is that
private void button1_Click(object sender, EventArgs e)
{
RecursiveClearTextBoxes(this.Controls);
}
private void RecursiveClearTextBoxes(Control.ControlCollection cc)
{
foreach (Control ctrl in cc)
{
TextBox tb = ctrl as TextBox;
if (tb != null)
tb.Clear();
else
RecursiveClearTextBoxes(ctrl.Controls);
}
}
hope finish of ur bug.
|
|
|
|
|
Hi,
I am starting the development of a chat server/client application and i would like to know how to call some kind of "world timer/clock".
I want my application both server and clients to share the same timer/clock.
Is there some cloth in the internet i can call when i start the server?
Thanks in advance
|
|
|
|
|
Hi
Nice Idea, Just use a common web service server for the client and server timer.
thanks
|
|
|
|
|
Hi All,
I've been trying various things for an hour now and can't crack this particular nut. I have this code that is throwing an enumeration exception:
string pathcategory = FileScore.OrderBy(input => input.Value).Last().Key;
foreach (KeyValuePair<string, int> kvp in FileScore)
{
FileScore[kvp.Key] = 0;
}
I think I see the problem. The first line is setting the order to the Value and then the foreach is attempting to iterate over the dictionary but each execution of foreach is changing the values that the enumerator is using ... how do I reset the ordering back to the key??
Thanks,
Jammer
Going where everyone here has gone before!
|
|
|
|
|
Just iterate over FileScore.Keys, then you won't be changing what you're iterating over, and it will work.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Christian,
Not sure that will work in this instance as its coded now. The dictionary is storing a list of possible matches to words in a string. Depending on the match i'm incrementing the value held against a key with potentially many matches to different words in the string, so I end up with a dictionary that might look like:
string1, 10
string2, 0
string3, 30
string4, 50
string5, 10
The line that sorts the dictionary is looking for and finding string4 and i'm passing that key back. Then I want to set all the values back to 0.
Would it be wiser to remove the sorting line and then just iterate over the dictionary holding the highest value in the key/value pair? Sorry if this is what you mean, just wanted to clarify.
Hope your well.
Jammer
Going where everyone here has gone before!
|
|
|
|
|
If you have a foreach and your code modifies what you are iterating over, it won't work. If you just iterate over the keys, I believe it will work.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Gotcha ... will have a look at that tonight.
Jammer
Going where everyone here has gone before!
|
|
|
|
|
I've just been testing this again and I've come to the conclusion that using a Dictionary as I am is a no go option ... no matter what I try there is an exception thrown.
foreach (KeyValuePair<string, int=""> kvp in FileScore)
{
if (FileScore[kvp.Key] > highestscore)
{
pathcategory = kvp.Key;
highestscore = kvp.Value;
}
FileScore[kvp.Value] = 0;
}
return pathcategory;</string,>
Even though the line that 'resets' the Value to zero isn't changing the Key the foreach throws an exception saying that the collection has changed. I think i'm going to use a normal generic list in its place.
Cheers,
Jammer
Going where everyone here has gone before!
|
|
|
|
|
Hi,
I encounter a very strange (at least to my understanding) behavior.
I have a Windows Forms program. In the program I use openfiledialog to choose some file.
Later on I save some data to an XML file using XmlDocument.Save().
When I write in the Save a specified path, e.g. "c:\\folder\\bin\\debug\\config.xml" it works fine.
But, when I write only a relative path: 'doc.Save("config.xml");' I get the strange behavior:
The config.xml file is save in the last folder the I visited when I used the openfiledialog control.
Wherever I visit with that control - the xml file is save into that folder.
I can't believe that this is the inteded behavior.
Did anyone encounter that?
Can it be something wrong in my code? If so - what king of possible mistake?
If it a bug of XmlDocument.Save() - how can I work around it?
Thanks in advance,
Itzik
|
|
|
|
|
It's not strange at all. When you don't tell the class where to save, it will save to the current directory. When you browse the file system, you're changing the current directory. Always tell a file where you want it to go, or you won't know where it is.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
"Relative path" is relative to the current directory, which by default is a place where an application was launched from. OpenFileDialog intentionally modifies the current directory to make access to a chosen file simplier. However, this behavior can be easily changed by setting OpenFileDialog.RestoreDirectory property to true.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Thanks a lot guys.
This was very helpful.
|
|
|
|
|
Hi,
I am trying to develop a toolbar using C#, MS Visual Studio. My OS is Vista. Whenever I make a change, I need to unregister and reregister the .dll file into GAC. I do this going to the command window in admin mode. However, when I use gacutil on my .dll file, I come across this Vista message "NTDVM.EXE stopped working". I tried to remove the .dll file manually by visiting C:\Windows\assemble\GAC. But it looks like there is no related directory.
Any feedback is greatly appreciated since I am stuck here.
Thanks..
|
|
|
|
|
Hi,
I have some dialog and on this dialog i have some button.
When press this button - i need that the user will choose some date.
What i mean is the i need some month dialog to open - but i don't know how to do it.
Thanks for the help.
|
|
|
|
|
use the DateTimePicker control
|
|
|
|
|
hi there,
I am writing C# program which contains SQL connection several times , I learned how to connect with the traditional way , but I have read that there is a way using he data set controls provided by the .Net framework
please I need sites to describe how,
your help is appreciated ,
Thanks
There is always something to learn
|
|
|
|
|
The right way to do this is to have one method for connecting to SQL Server, inside your data layer which contains the code to call all your stored procs. The traditional way to do this badly, is to write SQL code inside every page/form that uses it. The new disasterous way is to still write SQL in the presentation layer, but use methods provided by the controls to do it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Hi!
I need a simple way to round a Decimal variable to a specific number of decimals.
Any suggestions? Isn't there any function that works something like: math.round(theVariable, 2), to get 2 decimals?
/Joplinazz
|
|
|
|
|
Yes, there is, why did you guess there might me, and not look ?
Math.Round(12.42332334, 2, MidpointRounding.ToEven)
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Ok someone on here mentioned to me that I should use a printDocument to create the pages I want to create. Basically I have each child that has a record of their payments they have made. Now at the end of the year for each child I want to print the record for them. At the top of the page will be our information and social security numbers for tax purposes and below that in the center of the page will be the childs name.
Then below that will be 3 columns for the payments they made which look like this:
$75 --> Paid on: 03/03/08
and so on..
Now I have it print to a print document and you can view the information on my form (printPreviewControl). But when you click print preview, the layout is totally different from the printPreviewControl on the form. Why is this? When you click print preview and the dialog pops up it is missing half the information!
Is this the way I should be doing this or is there an easier/different way? It should also print all the information for all the children, not just one child at a time. So there will be multiple pages involved ( about 5 ).
|
|
|
|
|
Ok I have changed some things, but for some reason the printpreviewControl displays what I write to the printDocument. But the PrintPreviewDialog displays nothing? I have the printpreviewdialog document set to my printDocument1
whats wrong?
|
|
|
|
|
We really need to see your code to be able to tell you what you did wrong.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I will post it, its kind of long.. but here it is:
public void getChilds(int Ccount)
{
string path = Directory.GetCurrentDirectory();
DirectoryInfo dInfo = new DirectoryInfo(path + @"\Children\");
DirectoryInfo[] dirs = dInfo.GetDirectories();
printPreviewControl1.Rows = dirs.Length;
if (dirs.Length == Ccount)
{
currentChild = "Done";
return;
}
if (currentChild != "Done")
{
switch (Ccount)
{
case 0:
currentChild = dirs[0].Name;
currentChildPath = dInfo + dirs[0].Name + @"\";
break;
case 1:
currentChild = dirs[1].Name;
currentChildPath = dInfo + dirs[1].Name + @"\";
break;
case 2:
currentChild = dirs[2].Name;
currentChildPath = dInfo + dirs[2].Name + @"\";
break;
case 3:
currentChild = dirs[3].Name;
currentChildPath = dInfo + dirs[3].Name + @"\";
break;
case 4:
currentChild = dirs[4].Name;
currentChildPath = dInfo + dirs[4].Name + @"\";
break;
case 5:
currentChild = dirs[5].Name;
currentChildPath = dInfo + dirs[5].Name + @"\";
break;
case 6:
currentChild = dirs[6].Name;
currentChildPath = dInfo + dirs[6].Name + @"\";
break;
case 7:
currentChild = dirs[7].Name;
currentChildPath = dInfo + dirs[7].Name + @"\";
break;
case 8:
currentChild = dirs[8].Name;
currentChildPath = dInfo + dirs[8].Name + @"\";
break;
case 9:
currentChild = dirs[9].Name;
currentChildPath = dInfo + dirs[9].Name + @"\";
break;
default:
currentChild = "Done";
return;
}
childCount++;
}
else
{
return;
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
getChilds(childCount);
if (currentChild == "Done")
{
e.HasMorePages = false;
return;
}
else
{
float x = e.PageBounds.Left;
float r = e.MarginBounds.Right;
float y = e.PageBounds.Top;
float b = e.PageBounds.Bottom;
float c = e.MarginBounds.Width / 2;
e.Graphics.DrawString(top[0], new Font("Arial", 10), Brushes.Blue, r, y, new StringFormat(StringFormatFlags.DirectionRightToLeft));
y += 1 + new Font("Arial", 10).GetHeight();
e.Graphics.DrawString(top[1].ToString(), new Font("Arial", 10), Brushes.Blue, r, y, new StringFormat(StringFormatFlags.DirectionRightToLeft));
y += 1 + new Font("Arial", 10).GetHeight();
e.Graphics.DrawString(top[2], new Font("Arial", 10), Brushes.Blue, r, y, new StringFormat(StringFormatFlags.DirectionRightToLeft));
y += 1 + new Font("Arial", 10).GetHeight();
e.Graphics.DrawString(top[3], new Font("Arial", 10), Brushes.Blue, r, y, new StringFormat(StringFormatFlags.DirectionRightToLeft));
y += (new Font("Arial", 10).GetHeight() * 2);
e.Graphics.DrawString(currentChild, new Font("Times New Roman", 14, FontStyle.Bold ^ FontStyle.Underline), Brushes.Red, c - (currentChild.Length / 2), y, new StringFormat());
FileStream fileOpen = new FileStream(currentChildPath + "Paid.daycare", FileMode.Open, FileAccess.Read);
StreamReader fileSR = new StreamReader(fileOpen);
string strLine = fileSR.ReadLine();
times = 0;
y += new Font("Times New Roman", 14, FontStyle.Bold ^ FontStyle.Underline).GetHeight();
centerLine = y;
rightLine = y;
while (strLine != null)
{
if (times < 31)
{
y += 2 + new Font("Arial", 12).GetHeight();
e.Graphics.DrawString(strLine, new Font("Arial", 10), Brushes.Black, x, y, new StringFormat());
strLine = fileSR.ReadLine();
times++;
}
else if (times > 30 && times < 61)
{
centerLine += 2 + new Font("Arial", 12).GetHeight();
e.Graphics.DrawString(strLine, new Font("Arial", 10), Brushes.Black, c - strLine.Length, centerLine, new StringFormat());
strLine = fileSR.ReadLine();
times++;
}
else if (times > 60 && times < 91)
{
rightLine += 2 + new Font("Arial", 12).GetHeight();
e.Graphics.DrawString(strLine, new Font("Arial", 10), Brushes.Black, r, rightLine, new StringFormat(StringFormatFlags.DirectionRightToLeft));
strLine = fileSR.ReadLine();
times++;
}
}
e.HasMorePages = true;
}
}
A lot of that is to make it print like 30 lines, then if it is over 30 lines then it prints in the center of the page, then if it is over 60 lines then it starts printing on the right side of the page.
Now my problem is, that it prints correctly to the PrintPreviewControl, but it just prints a blank page when you click print!
private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
printDocument1.Print();
}
the printpreviewControl document is set to: printDocument1. The printDocument1 name is printDocument1, but why does it print a blank page when this code actually prints the information to the printDocument and it SHOWS it on the printPreviewControl?
|
|
|
|
|