I solved the issue by putting ProgressBar.Refresh() on top in the timer event before the text property of the progressbar gets changed. But before, I had put it in the bottom of timer and didn't work. Anyway, thanks for dealing.
I found the following code, that allows one to write a string on a ProgressBar ... Only thing is that I can't get it to work Can anyone else make it work, and if so ... what am I doing wrong?
// call the method
SetProgressBarText(progressBar1, null, ProgressBarTextLocation.Centered, Color.Black, SystemFonts.DefaultFont);
// Set the ProgressBar Text methodprivatevoid SetProgressBarText(System.Windows.Forms.ProgressBar Target,
//The target progress barstring Text,
//The text to show in the progress bar
//Where the text is to be placed
//The color the text is to be drawn in
//The font we use to draw the text
//Make sure we didn't get a null progress barif (Target == null)
thrownew ArgumentException("Null Target");
//Now we can get to the real code//Check to see if we are to add in the percentif (string.IsNullOrEmpty(Text))
//We are to add in the percent meaning we got a null or empty Text//We give text a string value representing the percentint percent = (int)(((double)(Target.Value - Target.Minimum) / (double)(Target.Maximum - Target.Minimum)) * 100);
Text = percent.ToString() + "%";
//Now we can add in the text//gr will be the graphics object we use to draw on Targetusing (Graphics gr = Target.CreateGraphics())
//The font we will draw it it (TextFont)new SolidBrush(TextColor),
//The brush we will use to draw it//Where we will draw itnew PointF(
// X location (Center or Left)
Location == ProgressBarTextLocation.Left ? 5 :
progressBar1.Width / 2 - (gr.MeasureString(Text,
TextFont).Width / 2.0F),
// Y Location (This is the same regardless of Location)
progressBar1.Height / 2 - (gr.MeasureString(Text,
TextFont).Height / 2.0F)));
Many thanks in advance
The only programmers that are better C# programmers, are those who look like this ->
the problem is im having a xls file and im opening it using workbook.open() and i select cell A10 and close it next time when i open the file i want the focus back on A1. i.e always the file is open the focus should be on cell A1 for that i used the macro which i stated in the previos thread. but i feel it would be better if i can do that also in the application.
below is the code
xls = xlApplication.ActiveWorkbook.Worksheets as Excel.Worksheet;
xls.Visible = Excel.XlSheetVisibility.xlSheetHidden;
xls = xlApplication.ActiveWorkbook.ActiveSheet as Excel.Worksheet;
focus back to cell A1
Is this going to be the same excel file you'll be opening every time? You could put an 'AutoOpen' macro in the excel file (which would run anytime the file is opened, just enable macros when you open it) to do all this preliminary stuff you're doing in C#. It would be much easier in VBA anyway.
I have a library C which controls a device and it's methods take enumerations as parameters.
Then I have a library B which references C and "wraps" the complex commands from library C in something useful and maintainable.
The last thing I have is an assembly A which does the UI stuff. It references ONLY library B.
Nevertheless B needs the values of the enumerations of C to control the device (and to fill comboboxes with the enum-Values)
I need a way to pass the information, which value of an enumeration is needed from A to B.
I do not want to reference C in A (that's how I would get the enumerations as well).
Which would be a good approach to solve this problem.
Why not reference C in A? If B references C and A references B, then you have to distribute C with application A anyway. If you want A to have access to the values of the enumeration, referencing C is the 'right' and easiest way to go about it.
I am quite new to C# and WPF especially. I have a form, with 2 listboxes on. The first looks up an xml file and gets some data items (themes), the next listbox is bound to the first, and gets some data (scenes) from inside the selected theme tag.
This works wonderfully.
I would now like to get the value of an element (FreeStyleCue) and use that in a c# function tied to the OnSelectionChanged handler.
However I cant work out for the life of me how to get the information from the FreeStyleCue tag.
Can anyone help me??
Here is the xml file.
<?xml version="1.0" encoding="utf-8" ?><br />
<theme name="Yellow" description="A yellow theme" order="1"><br />
<scene name="PreShow" order ="1"><br />
<description>For before the show yellow.</description><br />
<scene name="Scenex" order ="1"><br />
<description>During yellow show</description><br />
<theme name="Blue" description="A blue theme" order="1"><br />
<scene name="PreShow" order ="1"><br />
<description>For before the show</description><br />
<scene name="Scene1" order ="1"><br />
<description>During Show</description><br />