|
Events? Create an event, fire it at the end of Method1, and call Method2 in the callback function
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
What was happening is that sometimes the webbrowser1 couldn't load the document and i get the default html error page inside the webbrowser1. I want to load wb2 only if a html document has been fully loaded in webbrowser1 then load it in wb2. Can you please provide me some e.g for be better understanding too
Form1.cs
{
webBrowser1 = new WebBrowser();
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
path = "c:\a.html"
webBrowser1.Navigate(path);
Controls.Add(webBrowser1);
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (((WebBrowser)sender).ReadyState == WebBrowserReadyState.Complete )
{
//once the document is completely loaded
doc = webBrowser1.Document.DomDocument as mshtml.IHTMLDocument2;
doc.designMode = "On";
if (!webBrowser1.IsBusy)
{
wb2 = new WebBrowser();
wb2.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler (wb2_DocumentCompleted);
wb2.Navigate(path);
}
}
}
|
|
|
|
|
Ouch, apparantly its a pain in the arse to get any error codes from the webbrowser control. The 'best' solution is apparantly this:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.webbrowser.createsink(VS.80).aspx[^]
Set up your browser control like that, and use the NavigateError event. If you get a callback for the event, then the page has not loaded correctly, so you'd want something like:
bool error = false;
wb1_NavigateError()
{
error = true;
}
wb1_docComplete()
{
if(complete && !error)
wb2.Navigate(...)
}
There might be easier ways (there damn well should be) but i couldn't see them.
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
I have recently installed Visual Studio 2008 Standard Edition. I tried to add a report to a project and when I drag the ReportViewer to the form, it just puts it at the bottom and does not show it on the form. It also does not show the triangle in the corner to select the report. What am I doing wrong?
|
|
|
|
|
Are you sure that you are using ReportViewer from namespace Microsoft.Reporting.WinForms and not from WebForms?
The need to optimize rises from a bad design
|
|
|
|
|
Yes, the project was originally a VS 2005 Express Project. If I create a new project, I can add a report viewer to a form but it will not let me add a new form to this project and put a report viewer on it.
|
|
|
|
|
Sounds like a problem in references or in project file.
Could you reconstruct the project, meaning create a new project and add all references needed, then add all existing classes.
The need to optimize rises from a bad design
|
|
|
|
|
The project is rather large so i just created a new dll for the report viewer form and referenced it in the old project. That seems to be working. Thanks for your help.
|
|
|
|
|
No problem, your solution should also work fine.
The need to optimize rises from a bad design
|
|
|
|
|
Hi,
I'm having difficulty getting a section of an app.config file to show as encrypted. I run the code and get no errors, but the section does not encrypt. Any help would be appreciated, I've tried other implementations from other posts here with same results:
using System;
using System.Windows.Forms;
using System.Configuration;
namespace AppConfigRedux
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnUnprotect_Click(object sender, EventArgs e)
{
UnProtectSection("connectionStrings");
}
private void btnProtect_Click(object sender, EventArgs e)
{
ProtectSection("connectionStrings", "DataProtectionConfigurationProvider");
}
private void ProtectSection(string sectionName, string provider)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath);
ConfigurationSection section = config.GetSection(sectionName);
if (section != null && !section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection(provider);
config.Save();
}
}
private void UnProtectSection(string sectionName)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath);
ConfigurationSection section = config.GetSection(sectionName);
if (section != null && section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
config.Save();
}
}
}
}
|
|
|
|
|
Greetings again!
Can anyone please explain how to use the anonymous constructor with Dictionaries?
eg.:
public static Dictionary<string, UIElement> _controlList = new Dictionary<string, UIElement>()
{
};
Thanks in advance!
|
|
|
|
|
public static Dictionary<string, UIElement> _controlList = new Dictionary<string, UIElement>()
{
{ "Key1", value1 },
{ "Key2", value2 }
};
|
|
|
|
|
|
float a = (float)93.3;
float b = (float)2.3;
float c = a + b; // at this moment c = 95.60001;
Why? I meet this strange behavior not only in C#, but also in Javascript, Actionscript and PHP.
|
|
|
|
|
|
in addition to Dan's link, did you know you can declare a float as a literal by suffixing with an 'f' and save the expense of casting from a double (or int).
float a = 93.3f;
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I try to make it short:
If you compute float numbers, the computer uses "MachineNumbers" which are to a certain level adequate. So the computer has internal numbers which are taken when given a float to compute.
e.g the Machinenumbers are
0.1,
0.2,
0.3,
0.4,
0.5,
1,
1.2,
1.5,
2,
2.4,
2.5
now you pass the number 1.2 -> computer takes 1.2 because it exists
then you take 1.3 -> computer takes again 1.2 because it is the nearest "MachineNumber"
you summ them and allthough there would be a "MachineNumber" 2.5
the computer computes 1.2 + 1.2 and you get the nearest "MachineNumber" which is 2.4
That's been very simplified, but I hope that helps
|
|
|
|
|
Thanks to everyone for answers!
|
|
|
|
|
If you want to do floating point math, I've found that using the decimal type is more precise. Try it this way:
decimal a = 93.3M;
decimal b = 2.3M;
decimal c = a + b;
You should end up with precisely 95.6.
If you need to, you can follow that up by casting the result to a float or double as need be.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The caveat to using the decimal type is that unlike floats it's not implemented in hardware directly and is significantly slower to use as result. This isn't a problem if you're doing light computations, but if you're doing larger amounts of calculation working within the limits of native floating points may be needed.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
To further and agree with your statement, decimal should only be used for financial or monetary values in .NET. At least that is my rule of thumb.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
To really jump in on the good vibes agreeance bandwagon, if the 96.1000001 is annoying you, then you really should be using an appropriate format string when you display it to the user.
|
|
|
|
|
Additionally to what the others already said, it's not safe to compare two float values like this:
if(float1 == float2)
Instead, for floats you should rather use something like this:
if((float1 - float2) < delta)
where delta can be a small number like 0.001.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hello!
I'm currently fiddling around with pixel drawing on Windows Forms using VC# Express, and I'm crashing into this problem.
I want to try and set up Bitmap which is configured to 8-bit colours and make use of a ColorPalette object, but I'm having slight trouble how to set this up, as I'm quite new to C# compared to C/C++.
Here is my current code:
<< in the namespace/class: >>
Rectangle pixRect;
BitmapData pixData;
Bitmap pixBitmap;
Color[] myCols;
ColorPalette myPal;
<< in the form constructor: >>
unsafe
{
myPal = new ColorPalette();
pixBitmap = new Bitmap(50, 20, PixelFormat.Format8bppIndexed);
pixBitmap.Palette = myPal;
myCols = myPal.Entries;
pictureBox1.Image = pixBitmap;
pixRect = new Rectangle(0, 0, pixBitmap.Width, pixBitmap.Height);
myCols[0] = Color.FromArgb(255, 0, 255);
}
I can actually tell that "myPal" ColorPalette is no assigned, occording to a compile warning message, but there doesn't seem to be a ColorPalette constructor.
Any suggestions ?
Thanks in advance,
OCrowley.
|
|
|
|
|
OCrowley wrote: Any suggestions ?
Not sure. Do you have something against reading the documentation?[^]
led mike
|
|
|
|