|
okay i try that!!
thansk!!
|
|
|
|
|
I sense impending disaster.
|
|
|
|
|
|
That you're trying to make a malicious program.
Jeremy Falcon
|
|
|
|
|
Actually, it was more to do with the fact that he appeared to blindly ignore some of Heath's advice.
Heath Stewart wrote:
You also shouldn't just go stopping processes just so you can delete a file.
After giving this warning, Heath answered the question to which
QzRz wrote:
okay i try that!!
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
I am using the article Inserting XML formatted data into SQL Server 2000 By faisal abdul aziz as a template for some work I doing. I have create a class, in a separate class file, to cover the 'child' elements. I have called this Answers.cs.
The begining of the file looks like this:
using System;
using System.Xml.Serialization;
namespace SGC.Apps.Consultations
{
public class Answers
{
public Answers()
{
}
private int intQNo;
private int intAns;
[XmlAttribute]
public int Question_No {
get {
return this.intQNo;
}
set {
intQNo = value;
}
etc.....
In web form I have button_click event routine
private void Button1_Click(object sender, System.EventArgs e) {
if (Page.IsValid) {
XmlSerializer serlizer = new XmlSerializer(typeof(Replies));
int intCount = 2;
Answers[] ans = new Answers[intCount];
ans[1].Question_No = 3;
etc......
I get the error Object reference not set to an instance of an object
The highlighted line is 'ans[1].Question_No = 3;
Full error is [NullReferenceException: Object reference not set to an instance of an object]
Can anyone help with what stupid thing I am doing wrong?
cheers
Robert T Turner
South Gloucestershire Council
|
|
|
|
|
1: int intCount = 2;
2: Answers[] ans = new Answers[intCount];
3: ans[1].Question_No = 3;
I've numbered the lines above.
In line 2 all you are doing is reserving the space for the objects. You still have to create them. So after line 2 you need to do
ans[0] = new Answer();
Also, remeber that indexes in C# are zero-based. I don't know if you knew that, but it looked odd (line 3) that you were starting on index 1.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Colin Angus Mackay wrote:
Also, remeber that indexes in C# are zero-based.
To be complete, indexes in .NET are all zero-based.
[EDIT] Before the ignorant start flaming me for "indexes" check your dictionary. "Indexes" is a perfectly viable alternative to "indices". It's happened before. [/EDIT]
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I might be completely wrong (usually am) but i think you need to set the ans[x] = to an instance of the answer class before you can do anything with it. Because it has not been instantiated yet you get your Null Reference Exception.
Try initializing each element in the array to a blank Answer class.
This sounds right to me but without actually trying it i don;t know.
Let me know how you get on,
Cheers
Kev Pearman MCP
|
|
|
|
|
Thanks to you and all who replied
Robert T Turner
South Gloucestershire Council
|
|
|
|
|
Hi, I have a trivia program wherein i have main form containing a label for player's winnings. the trivia questions are separate forms that is launched when the corresponding button from the main form is clicked. the question forms are timed and once the time has expired, it checks for the correct answer. a price (i.e. $100) is set for each correct answer. the problem im having is that this price is not being updated on the main form label after the time has expired. Can anyone help me please ASAP?
thanks.
Sincerely,
Jason C. Ranin
Software Quality Assurance
|
|
|
|
|
Try calling the TextBox.Invalidate() method, this will force the text box to be re-drawn. If that doesn't work then it may be a problem with how you are passing the value into the text box.
Kev Pearman MCP
|
|
|
|
|
Hi,
I am trying to inventory a directorty with Word documents.
This is on of my first programs in VS, but this is what I've got:
Reference to Interop dll's for Word 2002.
Getting the files from the directory.
Opening the word docs one by one.
But then I'm having trouble getting the Toc of the document.
I want to insert the document per paragraph from the toc in a db.
I have read on MSDN but still no luck.
Does anyone have any tips for me?
Steven T
|
|
|
|
|
Hi,
I have some class in my project like Executive, Manager etc. Each class has some perdefined properties like FirstName, LastName etc. I assign the object of my classes to the property grid, to have these perfined properties in the property grid.
The problem is that i want to add some other properties like Address, Phone, Email etc to my classes (Manager, Executive) at runtime, so that these properties can also be accessed through the property grid. How can i do this.
Thanks in advance,
Omar Rehman
|
|
|
|
|
Please I need to know how to get my speed on the network.
|
|
|
|
|
The only way to accurately measure this property is to actually measure it. You need to send data of a known size to a network resource (i.e., your gateway/router or an intranet server) and measure how long it takes to completely send. You should also measure how long it takes to receive this data. You do this over and over again and measure the running average. This is how download managers calculate how much time is left while downloading a file.
You can also use a PerformanceCounter using the "Network Interfaces" category, the "Current Bandwidth" counter class, and the instance of the NIC (network interface card), which performs many of these calculations for you. This is not the actual bandwidth, however, this is only the max bandwidth as reported by the NIC.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I'm playing around with generics in .NET 2 beta framework.
in 1.1 i have expresion :
propertObjArr[i].PropertyType.IsSubclassOf(typeof(System.Collections.CollectionBase))
to find all properties in object which have been collections at runtime. Then i changed some collection into generic collection.but there is no abstract class for generic collections.My question is how to find out which properties are generic collections.
|
|
|
|
|
nevermind
i found propertObjArr[i].PropertyType.HasGenericArguments solve my problem.
|
|
|
|
|
Hello,
Can any one tell me dat is there a way that i can make my own control box with customized minimize, maximize/restore & close buttons & add this control box to any Form. Is there any class which represents Control Box or do i have to inherit generic windows Forms class or ?????
In short i want to put my own buttons (some fancy styles) where the minimize, maximize/restore & close buttons are on the top right of the form. Ony way is to set the ControlBox property of Windows form to false but then my menus are hidden behind the control box picture which i inserted in order to show a dummy control box.
Please help me out on this.
Regards.
Imran Ahmed Khan.
|
|
|
|
|
There is nothing in the .NET Framework BCL to help you create your own control boxes. You should extend the Form class, override WndProc , and handle the WM_NC* notification messages to draw in the non-client are of the window frame. There are many native APIs that you must P/Invoke, as well as many supporting structs you must define (like RECT , which cannot be replaced by System.Drawing.Rectangle - their fields have different meaning).
There are article on the 'net (try a google search) that describe how to do this using C/C++. If you know C/C++, I would suggest creating a Managed C++ project and using both managed and native code to extend the Form class to do what you need. You could then reference that assembly and extend or use that class in any managed language.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi all,
I'm trying to right align a string on a page and i know i can do it if i can find the width of the string i am printing in pixels (or another GraphicsUnit measurement). Does anyone know how i can find this out or does anyone have another way of doing this.
Cheers
Kev Pearman MCP
|
|
|
|
|
OOPS!!
Just read down the forum and saw the previous post on getting the size of a string in pixels.
This should be fine for what i want.
KP
|
|
|
|
|
OK,
i can get the size of the string in a SizeF object using the Graphics.MeasureString method.
The problem i have now is that the page bounds are in 100ths of an inch and i have the size of the string in pixels. My idea was to use the drawstring method and in the place of the x co-ordinate i was going to use:
e.MarginBounds.Right - stringSize.Width,
Obviously this isn't going to work because the 2 values are in different units. Is there a method that i can use to convert a value in pixels to a value in 100ths/Inch or vice versa.
Cheers
KP
|
|
|
|
|
I have a similar problem: I have the size of a bitmap in pixel, but I need to know the size in millimeters.
Some conversion can be done using the PrinterUnitConvert class, but unforunately it doesn't work with Pixel
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
I found this in the book "windows programming with C#" by Charles Petzold:
PointF ConvertMillimtersToPixel(Graphics grfx, PointF pointF)
{
pointF.X *= grfx.DpiX / 25.4f;
pointF.Y *= grfx.DpiY /25.4f;
return pointF;
}
Maybe you can enhance it for your needs...
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|