|
Thanks - I've got it working now!
|
|
|
|
|
Hi all...I am a novice in reports so if my question is stupid please let me know..I am working on an OMR application.I want to print an OMR sheet.I want the users to customize the sheet by selecting no of Questions and no of options.I am thinking about using a report to print the sheet.So my question is how could i make a report programatically by supplying the no of columns and rows...Is there any other alternative..Please help me folks as i am stuck..!
|
|
|
|
|
Is there anything available that will automatically take care of the < > & ' and " chars in a string upon adding it to an attribute in an XML node?
I don't have a problem with creating a function that escapes and unescapes the text in my class but kind if figured that this might be something that is already in there and I am just missing it.
I am looking around (have been for about 30 minutes so far) and am not finding anything so I thought I would ask. Usually Google gets me there pretty quick if it exists.
|
|
|
|
|
If you use the XML DOM classes it does do it for you.
using System;
using System.Xml;
class Example
{
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
XmlElement root = doc.CreateElement("root");
doc.AppendChild(root);
XmlElement child = doc.CreateElement("child");
root.AppendChild(child);
XmlAttribute attr = doc.CreateAttribute("example");
attr.Value = "<CodeProject ©>";
child.Attributes.Append(attr);
doc.Save(Console.Out);
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
You could always do this by using HttpUtility.HtmlEncode on the text. This converts the characters that Html doesn't understand into ones that it does, e.g. & becomes &.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I have a problem with a Windows Forms project I am toying with. I am creating a quicken like program. The main window creates a MDI child for each account (checking, credit card, and broker). I cannot figure out how to handle the close button. I want the form to just hide itself and remain in the main menu item that I dedicated to keeping the names of the children, so that the user can reselect and open the form again. However, this doesn't work:
private void CheckingAccountForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
this.Visible = false;
e.Cancel = true;
}
}
The window is removed from the menu, and I currently have no way to bring it back.
Ideally I would like to remove the close button from the header of the form but leave the other two. I can't see any way to get rid of that button without losing the others.
I may just get rid of the header and add two custom buttons for the other two functions (minimize and full/screen toggle).
Any ideas?
Another pesky problem is that if I click the close button on the main form, it closes the children but stays open, and I gotta click the close buttong again.
Thx.
|
|
|
|
|
I think you'll have to roll your own MDI window list if you want it to show hidden forms.
You can probably remove the close button from the child forms by using P/Invoke. I wouldn't though nor would I suggest you implement your own buttons for minimize and maximize. People expect those buttons to be there if the function can be done.
You must be doing something somewhere to prevent the closing. I put together a quick MDI application that maintains a window list, creates children, and hides children instead of closing them when requested (although I overrode the OnFormClosing method instead of creating an event handler).
|
|
|
|
|
Thanks. I did end up adding my own combobox to my toolstrip. I found that the way I am handling the form_closing event works, in that it keeps the MDI window in the parent's mdiChildren list. So, by setting the e.Cancel to true, the child stays in the list, but setting Visible to false causes it to be removed from the menu item.
|
|
|
|
|
I wrote a routine using some of the reflection features to look for paired member fields in a class. The function looks up this variable's value and the value of the paired variable, which may or may not actually exist. If it does, then its boolean value is read, and if true the function returns a System.DBNull.value, otherwise the function just returns the value of the named field passed into it when called.
Rather than use variant variables to store my database fields, I'm using two fields to store the value read from a database. The first is a typed field variable for the actual data, if it's not Null, and the second is a boolean to track if the database value was Null or not, i.e., Name and Name_Is_Null, both of which belong to an instance of the DataBase_Info class.
Currently, the function is called with a string containing the name of one of the member fields, and there is only one instance of DataBase_Info. Now I'd like to pass the actual field variable to the function, and have resolve the class instance, if there is a paired member, and return either the value passed in if their isn't a paired member or it's false, otherwise return System.DBNull.value. How can I resolve the name of a variable passed in as a parameter and its container at run-time?
Thank you
|
|
|
|
|
Rather than writing your own mechanism, why not just use strongly typed data sets, which do this all for you? They're easy to create, very robust, and with .NET 2.0 very flexible to change the underlying connection and fetch behaviors. Take a look at many of the search results on MSDN from http://search.msdn.microsoft.com/search/default.aspx?siteId=0&tab=0&query=strongly+typed+dataset[^].
As far as answering your question, you can use Type.Method or Type.GetMethods . With each MethodInfo , you can call MethodInfo.GetParameters . There are also other interesting and pertinent properties on MemberInfo you may need to pay attention to, like IsGenericMethod . Just depends on what methods you're reflecting and how they're written.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank you for your reply.
I've tried to stay away from using strongly typed data sets in favor of "self-healing" code. I'm forced to use VS2003 with .Net 1.1, so this may not be a problem with the later version(s), but when the database changes, i.e., a column goes from not null to null, we've had to update the strongly typed data sets and the programs. I'm more interested in having the code able to deal with nulls directly. However, I'll need to look at the link you gave, it may be that we're not using stongly typed data sets properly.
As I said in my first posting, I want to be able to create a class structure instance to contain all of my database column data. Currently I'm testing the columns for null as they are read from the database using a query. If the value is null then I set a paired member flag variable to true and a 0 or empty string, or some other default value in the value member variable, and if the column isn't null, then I'm setting the flag to false and store the column value in another member variable. The flag member adds the suffix '_Is_Null' to the name of the one used by the value member.
This works well enough, I just need to check the '_Is_Null' suffixed flag member to see if the database value was Null or not to determine how to use the value member variable. However, when it came to sending values back to the database via a stored procedure I wanted to "hide" this code so the assignments easier to read. Instead of passing both the flag member variable and the value member variable to the function in which I was hiding the test, I decided to pass the name of the value member into the function, and use Reflections to look up the paired flag member and its value, then return the appropriate value to be assigned to the stored procedure's parameter. This too works well enough, except that because I was passing in the name of the member as a string instead of the member's value, I'm not able to take advantage of the compiler check for misspelled member names. So, I want to use the value member instead of its name in the function call.
However, when I tried using them with the debugger I could see the data types of the parameters, but I couldn't figure out how to get the names of the variables passed in to them with the function call. Another issue is that Reflections tells me what the containing class's type name is, but not the instanced variable, so if I had more than one instance of the class, how would I know that I'm looking at the right instance when I resolve the paired flag member to see if it is Null (true) or a value (false)? In my current code I hard-code which parent class instance I'm using, this isn't a problem in this one case because there is only one instance of the class, but I'm pretty sure that Reflections techiques could be used inside the function to could get this information from the variable being passed in as the parameter.
Thank you
|
|
|
|
|
Hi folks,
I am nearing the end of the first cycle of developement for my application. We began this with the .net framework 2.0, However we are now interested in using WPF and for that it appears we need to upgrade to 3.0.
My question is does anyone know if migrating an application from .net 2 to 3 is a big task and would we need to undergo any major changes. Obviously at this stage we don't want to risk breaking the application too much and don't have the time to undergo any major reworking.
Thanks for your time
Darren Sim
|
|
|
|
|
.NET 3.0 is actually .NET 2.0 + WPF, WCF, and WF (WinWF). There should be no risk at all. Even going from .NET 1.x to 2.0 isn't a big risk. Very little gets removed or deprecated (deprecation is really only a problem for future Frameworks the currently desired version). The biggest thing to consider is the user experience of taking a new dependency that has little market penetration at the moment. For example, a reboot may be required before you can even set up your product.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath! It's been a long time since you've grace the forums with your presence! We've missed your infinite wisdom in everything Windows!
Welcome back!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
As you can see[^], I've been pretty busy.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
How many hours a day are you putting in?!
Looks like my life with the Fed Government! I swear, they go out of their way to break everything they can and still call it "Production Quality".
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Heath, here's a question for you. Does the /quiet switch tip also work for VS 2003 SP1?
|
|
|
|
|
Off the top of my head, no. That uses an older wrapper that doesn't support (because they didn't exist when it was written) the standard Microsoft command-line switches for update packages. You can search my blog for details.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
OK. Well I've installed VS 2003 SP1 at work and it wasn't too bad. I used the /quiet trick for VS 2005 SP1. Reason I ask is because at some stage I will be applying the SPs to my home versions.
Kevin
|
|
|
|
|
At the microsoft launch event, the presenters said that the .NET framework 3.0 is the same as .NET 2.0 but it includes WPF, WCF, and CardSpace (might be missing a category, but still). Your applications should work fine with .NET 3.0, but if you want to take advantage of WPF then you will need to rewrite the GUI aspect of your applications using the .NET 3.0 tools. But the source code change from .NET 2.0 to .NET 3.0 should not change.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Thats what I thought, but always better to be sure
I think recreating the GUI is not an option at this stage - it's almost complete as is, and the project deadline is looming ever closer (as always). This is something I will look into further in the future, as my application is using a layered architecture it should just be a case of replacing the GUI if required.
Thanks for your help guys
|
|
|
|
|
Hi,
Using pdflib library in C# I have created a pdf file which is
protected using owner password .Different options are disallowed like
print, copy contents etc. Things were working very fine untill i came
to know about some password crackers which could easily crack the
file , eliminating the password , thus making it possible for
operations like printing, copy etc .
The study showed that using user password as well will make the file
strong enough to be decrypted ,but "user password" is not a solution
in my case .
The code which actually creates a pdf file using pdflib is as under :
PDFLib obj = new PDFLib();
obj.begin_document(FileName, "masterpassword=23wdlm3ldjwld4w
permission={noprint}");
Now i wonder even that the file is encrypted using 128-bit
encryption , how a password cracker can retrieve that stored password
form the encrypted file .What operation is performed by the cracker to
remove the password and making the file accessible for all options .
Can any one please help me in this ....
Regards,
Madni
|
|
|
|
|
You can encrypt the file all you want, it won't help you. Your problem is that in order to use it, it has to be decrypted at some point before it's used. This is where the hacker is going to get his hands on the file and just do what he did before.
There is no way you can 100% protect the file. You can only slow the hacker down...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Even if you were to handle encryption on the server where every users is given a separate, licensed private key to decrypt, the user in your project would only need to bypass the upload for the server to encrypt the document. So long as anything executes on the clients' machines, you can't entirely prevent them from doing anything to your code. Dave's absolutely right: you can only slow them down.
Take recent events. Protection for HD-DVD and Blu-ray were both cracked by a good debugger finding the private keys stashed in an application that needed them to decrypt. They didn't hide them well enough. All other apps simply hide or obfuscate their keys. It's not impossible to get them.
If you read Bruce Scheier's wonder "Applied Cryptography", it reads (and is famous for stating) that givne infinite time and resources, anything is crackable; it's only a question of encryption strength vs. information worth that dictates when a cracker will get the information they want (or if they even bother).
Note that a distributed approach to solving your problem is about the best you can do. So long as each client gets their own decryption key (or you can developed a shared decryption for group management, which some DRM enables currently) you can at least revoke it on a per-person or per-group basis. A would-be cracker would need an individual's decryption keys or decipher the message the hard way without them.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi all,
I've got a little question about system colours and xp themes.
Most objects in windows xp change colour when you change theme. In the .Net framework you have the SystemColors enumeration which you can use for objects to be appropriatly coloured with each theme.
However, i've noticed there are some colours that aren't represented in this enumeration. For example, if you right click on a folder and go to properties, then to the customize tab, there are several group boxes with text on them. In the xp-default and silver color schemes, the text is blue, but change back to windows classic theme, and the text is black.
I've checked every system colour in the enumeration, and not a single colour is blue in both the xp-default scheme and the silver scheme.
I've looked around on google but can't find anything relating to this. Does anyone know what colours Windows is using. Obviously, i've considered the option of manually defining the colours, and altering them when the user changes the colour scheme, but there must be a simpler way than this.
Simon
|
|
|
|
|