|
hi,
i get an error when i try to remove the specific row ....which is following
Message = "Rows cannot be programmatically removed unless the DataGridView is data-bound to an IBindingList that supports change notification and allows deletion."
how can i change the data-bound configuration .
|
|
|
|
|
Hi,
I am developing an windows based application in which some print menu is present which prints the project information.
So i am using "PrintPreviewDialog" control in my application. But the problem is when there is no printer installed in my computer then it is not showing the preview.
but in microsoft word and others it is showing the preview so.
How to show print preview when no printer is installed on ur computer or no printer is connected to your computer. At least it should show the print preview. Is there is some method or some property.
I am using printdocument object in it.
Please guide me.
|
|
|
|
|
Is print preview enabled for Wordpad or MS Word on that computer?
I would just install a generic printer driver and it should work. The printer doesn't have to be plugged in to do a print preview.
|
|
|
|
|
Word, Excel is showing the preview.
But my application is not showing preview
|
|
|
|
|
Even i am also facing the same problem.Can anyone please suggest me the solution?
|
|
|
|
|
|
relative to what ?
No.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
|
Sorry for the delayed reply but thank you very much for the useful answer.
Kind Regards,
Mushq
|
|
|
|
|
Very much a beginner C# person.
I need something simple and I'm pretty sure it can be done. I need to go to a website and simply see if a date has changed. I it has I need to pull the date back in. The date always follows the same three words so it will be easy to find.
Thanks for any who can help
dflat4now
|
|
|
|
|
Not sure I fully understand this, but it sounds like you're talking about a specific web page, and you know roughly where to find this date on the specific page. That should be easy enough--just download the content to a string via http, then "find" the date in the string (i.e. by locating the "same three words"), trim the rest away so you just have the date text, then parse this into a DateTime object using either DateTime.Parse, or another (third party) date-parsing algorithm (there are some on CodeProject) depending on the format of the date.
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
Use WebClient class to download the webpage content. Write a regular expresssion which finds the required date.
|
|
|
|
|
as N a v a n e e t h posted, use regular expresssion, there is software on code project named "EXPRESSo" i think it will be helpful for you to build the regular expressions.
Regards.
Tasleem Arif
|
|
|
|
|
How do I do it? I created a class called "Category" that is essentially built from some strings and an int, and i need to be able to dispose of it when i am done (there are some issues arising from "used" objects not going away)
I am inhereting the IDisposable interface, but i know that does nothing beyonf requiring you to ad a dispose method. any suggestions?
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Vodstok wrote: I created a class called "Category" that is essentially built from some strings and an int, and i need to be able to dispose of it when i am done
There is nothing to dispose. You only need to use IDisposable if you are using unmanaged resources which you need to clean up, or you are using instances of classes that already implement IDisposable. Strings and ints fall in to neither category. The garbage collector will clean up the object when it is ready to do so.
|
|
|
|
|
ok, well that is a load off. This may be relevant to my problem: the object is being used as a static object. would that cause it to persist even though it has been "instantiated" with another identity? Essentially, the variable name is being reused on another page, but is returning all ofthe same information, even though it should be night and day different.
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Vodstok wrote: the object is being used as a static object
Do you mean that the class is declared as static:
public static class MyClass
{
}
Vodstok wrote: would that cause it to persist even though it has been "instantiated" with another identity?
I don't understand what you mean by that. A static object, once created, will persist for the life of the application. You don't "instantiate" the object directly, the CLR decides when to do that. It is possible that a static class won't be "instantiated" (actually, for static classes, the term is "initialised") at all.
Vodstok wrote: Essentially, the variable name is being reused on another page, but is returning all ofthe same information, even though it should be night and day different.
If it is static then there is only ever the one "instance" (if you like).
|
|
|
|
|
sort of. the class isnt static, but the instance is:
public class Category
{
private static Category cat = null;
public static Category Instance(int id)
{
if(cat == null)
cat = new Category();
return cat;
}
Just an example snippet, but that is the gist of it
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Vodstok wrote: the class isnt static, but the instance is
Okay - You are using the singleton pattern (which ultimately should produce the same effect as a static class - except you have a lot more work to do)
So, with that in mind, back to what you said earlier:
Vodstok wrote: ok, well that is a load off. This may be relevant to my problem: the object is being used as a static object. would that cause it to persist even though it has been "instantiated" with another identity? Essentially, the variable name is being reused on another page, but is returning all of the same information, even though it should be night and day different.
Assuming that the Instance method is the only thing that creates an Instance of the Category class (and that the constructor which isn't shown is private*) then it will get created once, and once only. The logic does not permit any other instance to be created.
It doesn't matter where in your application you access this, you will always get the same instance back.
* Which is normal for a singleton
|
|
|
|
|
For starters, you answered a question i have had for a long time, whihc was "what the hell is this method of creating objects called", so THANK YOU, it has been eating at me since i was introduced to it last year.
So let me see if i understand this properly. I use the method Category.Instance(1) to create an instance of an object, then go back and create Category.Instance(4), I now have 2 distinct objects that should not overlap in any way shape or form?
I may have another unrelated problem, but as long as Ikno where not to loolk, i will be better off
Again, Thank you
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Vodstok wrote: I use the method Category.Instance(1) to create an instance of an object, then go back and create Category.Instance(4), I now have 2 distinct objects that should not overlap in any way shape or form?
No, you still only have one object. I've annotated your code below:
public static Category Instance(int id)
{
if (cat == null)
cat = new Category();
return cat;
}
The logic prevents the creation of a new instance. cat is a static field, which means there will only be one regardless of how ever many instances of the class you create.
If you want to create new distinct objects through a method you may want to look at the Factory Pattern instead - the code above is part of the Singleton Pattern. (Are you familiar with design patterns? Or have you just muddled through and stumbled upon them without realising? - Both scenarios are good in different ways).
The Factory Pattern is a design pattern that permits a method (or class) to be responsible for the creation of objects. It can be a lot more flexible than using basic constructors.
The Singleton Patterns is a design pattern that constrains a class so that there will only ever be one instance of the class. In C# this is more commonly achieved by using a static class (i.e. the pattern is built in to the language). In other languages you can do this by controlling all instantiation through a single method (this is what you are doing in your code)
|
|
|
|
|
I found out what my problem was....
i have the block that starts with if(cat == null), and all of the logic assigning values to the various strings and ints in the object were contained in that block, so when i feed it a new id, it does nothing with it, exactly the way i coded it.....
______________________
Oh Hamburgers!
|
|
|
|
|
Vodstok wrote: I found out what my problem was....
This is what happens when I start writing a reply, get distracted, come back and finish it off... You find the answer by yourself.
|
|
|
|
|
I appreciate you taking the time, and to answer the question in your other post, I have been muddling around in this pattern with no clear understanding of how it worked, but just that it made my life way easier.
I have not ever looked at desing patterns.
______________________
Oh Hamburgers!
|
|
|
|
|
Vodstok wrote: I have not ever looked at desing patterns.
You might want to look out for a book on the subject. There are books on design patterns in C#, or there are generic books that apply to any language. It would seem to me that you have figured out, or almost figured out, some on your own. Reading up on the subject will help get you a better understanding, and you can short circuit some of the trial and error of getting the thing right in the first place. It will also give you some good ideas of how to proceed in areas where perhaps you are still figuring things our, or have a solution that just does not feel right.
Once you have studied the basic patterns you can migrate on to some of the more interesting (in my opinion) patterns as given in Martin Fowler's book Patterns of Enterprise Application Architecture (IIRC). I wouldn't jump in to that book straight away though, it's a reference book for the most part, you'd need to understand the basics to get the best out of it.
Good luck.
|
|
|
|