|
you can't successfully call Dispose() on an Image inside a PictureBox.
this would be the proper way to switch a PictureBox from image1 to image2:
Image newImage=...;
Image oldImage=pb.Image;
pb.Image=newImage;
if (oldImage!=null) oldImage.Dispose();
|
|
|
|
|
Hi Luc,
Thanks for replying.
You made me think about what was going on and yes sir problem solved.
Seeing that I disposed of the images after every loop it's quite obvious that in the next run no images were available.
The solution was actually fairly easy.
Before I dispose of the image I use a boolean expression to determine whether or not an image is present.
Like this:
if (PictureBox[pictureBoxNumber].Image != null)
{
PictureBox[pictureBoxNumber].Image.Dispose();
}
Greetz and thanks for the insight,
Jeff
|
|
|
|
|
that is not good enough, you can't dispose of that image as it is still in use by the PictureBox itself,
you really should do it the way I have shown: copy the reference to a local variable, remove the image from the PictureBox, and only then dispose of it.
modified on Friday, January 15, 2010 7:40 AM
|
|
|
|
|
Hi,
my regex works fine in a regextest tool its just only when i try to filter the content via c# it doesnt work. here is my code
string fName = @"data.txt";
part of the content that should match
<div class="middleadimggold">
<a class="asdf" href="http://www.asdf">
asdf</a>
<p>
asdf</p>
<p>asdf</p><p>asdf</p>
<p><span class="blue">asdf</span>
<a class="de" href="http://www.4asdf"><span class="a">(See on map)</span></a></p>
<p><span class="blue">asdf</span></p>
<span class="xx">
asdf
</span>
</div>
please note the spacing in the content, not sure if it matters?
modified on Thursday, January 14, 2010 10:06 PM
|
|
|
|
|
ok this fixed the problem
if (Regex.IsMatch(allRead, regMatch, RegexOptions.Singleline)
singleline option that is. thanks for nothing
|
|
|
|
|
Didn't I tell you that yesterday[^]?
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
you have asked question by your-self and replied it back too again with answer already given by someone.
♫ 99 little bugs in the code,
99 bugs in the code
We fix a bug, compile it again
101 little bugs in the code ♫
|
|
|
|
|
How to convert Any type file (bmp,Jpg,jpeg etc...)to binary or blob file to store it in sql 2005.
|
|
|
|
|
Any file (including text file) is a binary file. You can treat any file as a binary large object (blob) to be stored in a database. You don't need to do any conversion. Any comments on this opinion are welcome.
|
|
|
|
|
correct. Any file is binary, some files also are text files, others also are image files, etc.
|
|
|
|
|
|
I am trying to use the amazon web services in my c# program but I kept getting a http 410:gone error.
I did some research and found webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl is suppose to be the correct web reference. In any event, the following appears to be obsolete and I can not find it replacement. What I am wanting to do is query amazon based on a title and return the price.
I thought AmazonSearchService srchrequest = new AmazonSearchService(); would work but that appears to have been replaced and i haven't a clue with what. I thought maybe AWSECommerceService srch = new AWSECommerceService();
Then also the KeywordRequest kr = new KeywordRequest(); has been removed. so I guess how do you do keyword searches now?
I was hoping to do something like this
ProductInfo pi = srch.KeywordSearchRequest(kr);
Details[] allDetails = pi.Details;
allDetails no longer exist either
Am I going about this all wrong or what? I can't seem to figure it out..
The closest I see are two things in the object brower. Price and then itemsearchrequest but I can't seem to figure out how one would use that to get the price of the item.
any help or a reference to a working tutorial or something would be great.
thanks
|
|
|
|
|
This documentation[^] may be of some help.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
Thanks for that link..
Here is something I came up with but for some reason It keeps throwing an exception.
The assembly with display name 'book list project.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1.
The cause of the failure was: System.IO.FileNotFoundException:
Could not load file or assembly 'book list project.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
The system cannot find the file specified.The assembly with display name 'book list project.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1.
The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'book list project.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
here is the code I'm calling:
private void btn_GetPrice_Click(object sender, EventArgs e)
{
AWSECommerceService aws = new AWSECommerceService();
ItemSearchRequest request = new ItemSearchRequest();
request.SearchIndex = "Books";
request.Power = "title:" + titleTextBox.Text;
request.ResponseGroup = new string[] { "Small" };
request.Sort = "salesrank";
ItemSearchRequest[] requests = new ItemSearchRequest[] { request };
ItemSearch itemSearch = new ItemSearch();
itemSearch.AssociateTag = "XXXXXX";
itemSearch.SubscriptionId = "XXXX";
itemSearch.Request = requests;
try
{
ItemSearchResponse response = aws.ItemSearch(itemSearch);
Items info = response.Items[0];
Item[] items = info.Item;
for (int i = 0; i < items.Length; i++)
{
Item item = items[i];
priceTextBox.Text = item.ItemAttributes.ListPrice.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
|
|
|
|
|
how to convert string like 0.5555 to rounded double value of 0.6 in this case? Because when i use Convert.ToDouble("0.555555") the result is 55555555..
Thanks
|
|
|
|
|
Hi,
the Convert class (or the Parse methods of several classes) will turn a string into a numeric value that matches the string as good as it can. There is no way around that.
You can change the result by adding another statement that operates on the numeric variable, something like double d=Math.Round(d,1); . AFAIK there isn't a single statement that will do both at once.
read up on the Math.Round() method.
|
|
|
|
|
Still..you can't convert string 0.555 to double value 0.555? Always removes 0 from first place..i used another more complicated way..i separate string..i get second decimal..check if it is greater than 5..if yes i inc first decimal and at the end i put numbers converted to string back together.
|
|
|
|
|
Aljaz111 wrote: you can't convert string 0.555 to double value 0.555
Of course you can, just use double.Parse or better still TryParse
double d = double.Parse("0.555");
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Aljaz111 wrote: Always removes 0 from first place..
Is the decimal separator in your country by any chance a comma? How about this for verification;
string s = "0.55555";
double d = Convert.ToDouble(s, System.Globalization.CultureInfo.InvariantCulture);
string s2 = d.ToString("#,#0.0");
Console.WriteLine(s2);
I are Troll
|
|
|
|
|
|
Good thinking
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks
I are Troll
|
|
|
|
|
Ok it doesn't work without System.Globalization.CultureInfo.InvariantCulture but with it in Convert.Double(s, System.Globalization.CultureInfo.InvariantCulture) works just fine. Can you explain me please what does this have to do with rounding numbers?
Thx
|
|
|
|
|
It interprets the decimal point wrong, if you replace the point with a comma then all goes well. There's also a System.Globalization.CultureInfo.CurrentCulture .
The invariant culture will use the decimal-point, no matter what's been set currently by the user. If you convert the double "2.0" from invariant to your CurrentCulture[^], then you'd probably get "2,0"
I are Troll
|
|
|
|
|
I'm not quite sure how you're approching this but it's quite simple
public static double StringToRoundedDouble(string s, int decimals)
{
double result;
if (double.TryParse(s, out result))
result = Math.Round(result, decimals, MidpointRounding.AwayFromZero);
return result;
} Useage
double d =(StringToRoundedDouble("0.5555", 1);
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|