|
I just started learning .Net and C#.
I come from C++ background.
When I declare a class vble
// class A is defined;
A a;
a = new A();
This object a is allocated in heap right? and its a reference type?
It seams all class variables are reference types. And it looks like a class pointer to me when I relate to C++.
Any good article?
thanks,
Misha
Evil traiumphs when good people sit quiet...
|
|
|
|
|
|
misha_grewal wrote: This object a is allocated in heap right? and its a reference type?
Correct.
It seams all class variables are reference types.
That's right. A class is always a reference type, and a struct is always a value type.
And it looks like a class pointer to me when I relate to C++.
A reference is implemented as a pointer, but it's easier to use in the code. You don't have to dereference a reference to get to the object, as you do with a pointer.
---
single minded; short sighted; long gone;
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
{
int n = 0;
textBox2.Visible = false;
textBox1.Visible = false;
while (n<100)
{
Thread.Sleep(100);
n++;
}
}
when I click the button, the textBox1 and textBox2 still visible! After 10sec, they are invisible,why?
NOTE:this code run in PPC, if run in WINDOWS, that two textBox will invisible after I click the button,is difference in PPC,why?
|
|
|
|
|
while (n<100)
{
Thread.Sleep(100);
n++;
}
You are making your UI sleep for 10 seconds -- once it gets out of the loop, the graphics object gets invalidated and the Paint handler gets to repaint your boxes (as invisible).
|
|
|
|
|
Hello,
You have to call:
textBox2.Visible = false;
textBox1.Visible = false;
Application.DoEvents();
bevore you start the Thread.Sleep
All the best,
Martin
|
|
|
|
|
How can i print an image using GDI+ in C# in avery dennison ap 4.4 printer. It is a ticket printer which accepts 3.9cm X 7.9 cm sheet?
|
|
|
|
|
Does anything in the System.Windows.Forms (such as the PrintDialog class) work?
If not, and you need to go outside the .NET framework for this, you can use P/Invoke[^] to call Win32 APIs.
|
|
|
|
|
I tried it came in reverse order with lot of space left on top. It should exactly match the ticket. So i need to adjust the printoutput same as ticket size. All these are readonly properties. I saw one PrintTicket class(in System.Printing namespace and in 2.0 all these are in System.Drawing.Printing namespace) in .Net framework 3.0. But there also same issue. print is coming in 3 tickets instead of one.
|
|
|
|
|
Hi guys,
I have tried numerous ways to export a report to PDF and I keep failing. Please help me, I am trying to export a crystal report from crystal report viewer to .pdf format automatically. Here is my code, it creates the report but it is not a .pdf and doesn't open in acrobat.
O_Report.Load(@"C:\Documents and Settings\sameer.patwa\My Documents\Project Files\POS\POSPymt\Invoice.rpt");
O_Report.Database.Tables[0].ApplyLogOnInfo(LogInfo);
pv.Value=SlsId;
pvs.Add(pv);
O_Report.DataDefinition.ParameterFields["Ad_Parameter1"].ApplyCurrentValues(pvs);
ExportOptions exp= new ExportOptions();
ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions ();
DiskFileDestinationOptions dsk = new DiskFileDestinationOptions();
exp = O_Report.ExportOptions;
exp.ExportDestinationType = ExportDestinationType.DiskFile;
exp.ExportFormatType=ExportFormatType.PortableDocFormat;
dsk.DiskFileName = @"C:\" + SlsId + ".pdf";
exp.DestinationOptions = dsk;
O_Report.Export();
sasa
|
|
|
|
|
The following method and code extract shows how I return to a browser in pdf format. I am not using the viewer in this example.
Stream ReportStream = GenerateReport(rptFileName, ds, ParmList);
MyPage.Response.Clear();
MyPage.Response.Buffer = true;
MyPage.Response.ContentType = "application/pdf";
MyPage.Response.AddHeader("Content-Length", ReportStream.Length.ToString());
byte[] ByteReport = new byte[ReportStream.Length];
ReportStream.Read(ByteReport, 0, (int)ReportStream.Length);
MyPage.Response.BinaryWrite(ByteReport);
MyPage.Response.Flush();
MyPage.Response.Close();
private Stream GenerateReport(string rptFullFileName, DataSet dsReport, ArrayList alRptParam)
{
ReportDocument crReport = new ReportDocument();
//Load the report file (name.rpt)
crReport.Load(rptFullFileName);
// Load the parameters if any
for (int index = 0; index < alRptParam.Count; index++)
crReport.SetParameterValue(index, alRptParam[index]);
// Set the datasource we use datasets
crReport.SetDataSource(dsReport);
return (crReport.ExportToStream(ExportFormatType.PortableDocFormat));
}
Tom
|
|
|
|
|
Thank you for your response Tom. I appreciate it.
I got my code to work, the problem was with my filename, it had a colon in it which was throwing it off.
sasa
|
|
|
|
|
I wish to create a property of a control which is an array of Images, such that I can add, edit and delete images in the VS2005 property window. I've created the property as:
private Image[] _myImages;
public Image[] MyImages
{
get { return _myImages; }
set { _myImages= value; }
}
The property appears in the property window, with a button that brings up the Image Collection Editor (empty, as expected). However, when I press the add button, I get the message "Cannot create an instance of System.Drawing.Image" because it is an abstract class."
If I prepopulate my array with "private Image[] myImages = new Image(3)"
It shows up as an array tree with three (none) images. I can edit each of these (good), but unless I set all of them to something (non null), I am unable to save the form (error is "Code generation for property 'MyImages' failed. Error was: 'Object reference not set to and instance of an object."
I have no trouble includeing a single Image as a property, nor do I have any trouble with an array of strings.
Any Indication as to what I may be doing wrong?
|
|
|
|
|
I'm not certain what to do here, but I have a few tips that might point you in the right direction.
I bet that the key is some attributes on your property that tell Visual Studio what to do with it. I recommend looking at the source code for existing controls that hold arrays or lists. For example, look at the attributes on System.Windows.Forms.ImageList and see how it's being done.
Alternately, to diagnose errors like these, you can attach a VS debugger to Visual Studio, then get the first Visual Studio to throw an error. The debugger should step into your code and show you what piece of your code is throwing an error up to the designer. Read more about this here[^].
|
|
|
|
|
HOW TO CHANG BACKGROUND COLOR IN 1 ROW
q1: I HAVE MANY ITEM 11 ROM BACKGROUND COLOR IS RED BUT I HAVE 2 ROW TO CHANG
BACKGROUND ONLY HOW?
q2: HOW TO HIGHLIGHT LIST VIEW IN EACH ROW
thanks
|
|
|
|
|
First of all, stop writing in all caps. That's the quivalent of shouting on the web. Don't do it.
Secondly, I realize English may not be your first language, but in any event, your sentences are so broken it's difficult to understand what you're asking. Perhaps you could more carefully craft your question in English, or post on a board of your native tongue.
To answer your questions, I will try my best to understand what you're asking.
abcomp01 wrote: q1: I HAVE MANY ITEM 11 ROM BACKGROUND COLOR IS RED BUT I HAVE 2 ROW TO CHANG
BACKGROUND ONLY HOW?
It sounds like you're asking how to change the background color of an item. What kind of item? I assume from your 2nd question that you're wondering how to change the back color of a Windows Forms ListViewItem. If so, look at ListViewItem.BackColor property.
abcomp01 wrote: HOW TO HIGHLIGHT LIST VIEW IN EACH ROW
I don't know what you mean by this. Can you clarify?
|
|
|
|
|
now i know listView1.Items[0].BackColor = Color.Red;
.......... srry u should before answer
"" q1: I HAVE MANY ITEM 11 ROM BACKGROUND COLOR IS RED BUT I HAVE 2 ROW TO CHANG
BACKGROUND ONLY HOW? ""
|
|
|
|
|
BackColor = myListView.BackColor?
Once again, I have no idea what you're asking.
|
|
|
|
|
I recently reinstalled visual studio, but now when i try to add a class (project -> add class) instead of having a class, i have an option to add an interface...and instead of windows form i have inherited form.
Is there a way to add the form and class templates?
|
|
|
|
|
have you tried the /resetsettings switch when running devenv?
|
|
|
|
|
um, i don't really know how to do that =[
and it's a fresh installation so i don't know if resetting settings would help, it's already it's default
|
|
|
|
|
Start up Visual Studio by the command line, passing /resetSettings as a command line argument.
If you don't know how to start applications with command line arguments, you should learn how to do that before continuing programming.
Does right-click on your project -> New Item... -> Class work?
|
|
|
|
|
i did resetsettings and it didn't work, and when i right click-add item on my project i don't have a class but when i do the same on the solution i do...=\
|
|
|
|
|
Maybe your project's type, intentional or not, is such that it can not hold classes.
sharpiesharpie wrote: when i do the same on the solution i do...=
I doubt that, the only thing a solution can hold is projects.
Did you have disk problems ? Did you edit solution/project files manually ?
I suggest you try again, at least with a new project inside the existing solution;
better yet with a new solution and new project.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
obviously...i said it's been that way since i installed VS (after formatting) =/
|
|
|
|