|
|
Sorry, I can't do that.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I use this code. but does not work. please tell my mistake
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap bm = new Bitmap(10, 10);
Graphics g = Graphics.FromImage(bm);
int dpix;
dpix = Convert.ToInt16(g.DpiX);
int dpiy;
dpiy = Convert.ToInt16(g.DpiY);
bm.Dispose();
g = e.Graphics;
int w;
w = Convert.ToInt16(this.Panel1.Width * g.DpiX / dpix);
int h;
h = Convert.ToInt16(this.Panel1.Height * g.DpiY / dpiy);
bm = new Bitmap(w, h);
this.Panel1.DrawToBitmap(bm, new Rectangle(0, 0, w, h));
e.Graphics.DrawImageUnscaled(bm, 0, 0);
bm.Dispose();
}
|
|
|
|
|
|
|
i set the panel's largest, still does not
|
|
|
|
|
help me please
|
|
|
|
|
So how is it related to C#?
|
|
|
|
|
Hi
I want to export Datagridview to excel. I have formatted my datagridview such that he negative values are shown as red, some values are bold and other formatting styles are applied. I want when I export it to Excel then it export with same formatted type.
Currently I Am using the below function to export. But unable to export with formatting.
private void exportAsExcel()
{
Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();
// creating new WorkBook within Excel application
Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
// creating new Excelsheet in workbook
Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
// see the excel sheet behind the program
//Funny
app.Visible = true;
// get the reference of first sheet. By default its name is Sheet1.
// store its reference to worksheet
try
{
//Fixed:(Microsoft.Office.Interop.Excel.Worksheet)
worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets["Sheet1"];
worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.ActiveSheet;
// changing the name of active sheet
worksheet.Name = "Sheet1";
// storing header part in Excel
for (int i = 1; i < dgvDetails.Columns.Count + 1; i++)
{
worksheet.Cells[1, i] = dgvDetails.Columns[i - 1].HeaderText;
}
worksheet.get_Range("A1", "AZ1").Font.Bold = true;
worksheet.get_Range("A1", "A" + (dgvDetails.RowCount + 2).ToString()).Font.Bold = true;
// storing Each row and column value to excel sheet
for (int i = 0; i < dgvDetails.Rows.Count; i++)
{
for (int j = 0; j < dgvDetails.Columns.Count; j++)
{
worksheet.Cells[i + 2, j + 1] = dgvDetails.Rows[i].Cells[j].Value.ToString();
}
}
}
catch (System.Exception ex)
{
}
finally
{
app.Quit();
workbook = null;
app = null;
}
}
Thanks in advance
|
|
|
|
|
|
|
How to open a document using word automation and read the bookmark values in it?This has to be done as a function...input of the function will be the full path of the file to be opened and a list of bookmark names.
|
|
|
|
|
|
Thank you but i am not able to goto the bookmark and bookmark names are not displayed(dont know whether i had inserted bookmarks correctly,please check).Following is the code:
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
object fileName = strFileName;
object readOnly = false; object isVisible = true;
object missing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc";
oDoc = oWord.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
oDoc.Activate();
Word.Paragraph oPara1;
oPara1 = oDoc.Content.Paragraphs.Add(ref missing);
oPara1.Range.Text = "Heading 1";
oPara1.Range.Font.Bold = 1;
oPara1.Format.SpaceAfter = 24;
oPara1.Range.InsertParagraphAfter();
Word.Paragraph oPara2;
object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oPara2 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara2.Range.Text = "Heading 2";
oPara2.Format.SpaceAfter = 6;
oPara2.Range.InsertParagraphAfter();
Word.Paragraph oPara3;
oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oPara3 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara3.Range.Text = "This is a sentence of normal text.Now here is a text";
oPara3.Range.Font.Bold = 0;
oPara3.Format.SpaceAfter = 24;
oPara3.Range.InsertParagraphAfter();
oDoc.Paragraphs[1].Range.InsertParagraphBefore();
object bm1 = oDoc.Paragraphs[1].Range;
Microsoft.Office.Interop.Word.Bookmark bookmark1 = oDoc.Bookmarks.Add("bookmark1", ref bm1);
bookmark1.Range.Text = "bm1";
oDoc.Paragraphs[2].Range.InsertParagraphBefore();
object bm2 = oDoc.Paragraphs[2].Range;
Microsoft.Office.Interop.Word.Bookmark bookmark2 = oDoc.Bookmarks.Add("bookmark2", ref bm2);
bookmark1.Range.Text = "bm2";
int nCount;
nCount = oDoc.Bookmarks.Count;
for (int i = 0; i < nCount; i++)
{
object objI = i;
MessageBox.Show(oDoc.Bookmarks.get_Item(ref objI).Name);
}
modified on Tuesday, May 17, 2011 7:07 AM
|
|
|
|
|
I'm doing a project in .net for little kids. So i need my UI to be eye catching. I'm hoping to use FLEX to do that.
first of all is it possible?
If so how can I do it?
Any help will be appreciated
Thanks.
|
|
|
|
|
Good god man, just use Windows Forms! Or maybe WPF (like Windows Forms, but all fancy smancy looking). But Flex (a Flash technology, right?) inside of Windows Forms... why oh why would you inflict that upon yourself?
|
|
|
|
|
Thanks for your reply,
But I've developed several components which are needed using FLEX. So now I have to integrate them with the win form.
Therefor I can't migrate to WPF now
|
|
|
|
|
If you want to do it in .Net, use WPF. It is quite good at flashy and unconventional UIs. If you want to use Flex, use Flex and make a SWF. Integrating them may be possible but it certainly won't be nice, you'd almost certainly be better off rewriting the custom controls you need. (Customising controls in WPF is quite easy, you can edit the template XAML.)
|
|
|
|
|
In case you haven't found out yourself, Adobe has some integration tutorials here.
|
|
|
|
|
hi,
What is a realTime application?
Is it one with multithreading?
If an application uses background worker process, can it be a realtime application?
Thanks
|
|
|
|
|
|
Thanks for the link.
I had read this before but do not really understand it.
Thanks
|
|
|
|
|
Sometimes computers need to things which must finish before or at a particular time, or length of time. Sometimes real-time systems are very important and will result in bad things happening if they do not work. Anti-lock brakes on a car are an example of a real-time computing system it would be bad if the system, did not release the brakes at the correct times as it might mean the car will crash and people going to hospital.
Some real time systems are not allowed to be naughty at all and cannot miss one deadline as this is a failure, some are allowed to be a little bit bad and miss some deadlines because missing a deadline is not too bad as the computer's answer can be ignored, some systems can miss lots of deadlines but the information they give is more useful the closer it is to the deadline.
Some people mix up real-time and high performance: A supercomputer doing hard maths is peforming well but not working in real time. The anti-lock brake doesn't have much to do before it reaches it's deadline so it's performance is not high, but it does have to finish before the deadline, so it is real time.
|
|
|
|
|
arkiboys wrote: What is a realTime application?
It is a system where response time is of most importance. We all have performance related requirements but the application does not fails if those are not met. For real time, processing time is one of the requirements.
arkiboys wrote: Is it one with multithreading?
Not all multi-threaded applications are real time. IMHO threading and real time do not relate.
arkiboys wrote: If an application uses background worker process, can it be a realtime application?
Yes. If the background thread does the work and reports back to the main thread within the time limits, it can be.
Note after Keith's reply: A real time application does not mean that it is very fast with processing. It means that it always processes within the given time limit. If it does not, it is a failure.
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
modified on Monday, May 16, 2011 5:02 PM
|
|
|
|
|
d@nish wrote: It is a system where response time is of most importance. We all have performance related requirements but the application does not fails if those are
not met. For real time, processing time is one of the requirements.
I just think it is worth clarifying as it can be read two ways IMO: It is not the fastest possible response time that is the issue (though often real-time systems do need good response times) it is more the time of the response to meet a deadline that defines a real-time system.
(for the OP's benefit)
If you are writing software to process the image on a TV sceen in real time, the image must be ready before the screen refreshes at its regular interval. Lets say the screen is 60 Hz, that means you have 1/60th of a second to get ready. If the code is guaranteed to finish in 1/59th of a second, that is good enough, you do not need to write a higher performance processing route for screen. There are reasons you might write a better performing routine (e.g. support for higher end screens) but you don't need to for this screen.
|
|
|
|