|
peace & serenity
|
|
|
|
|
Hi There
I am using Aspose.pdf to generate pdf documents.
The pdf document contains a table which is populated with data from a database.
I have the problem that if the table needs to continue to the next page, the pdf does not generate.
Is there any code that I need to include to allow the document to continue to a new page?
Regards,
|
|
|
|
|
hi,
you can use itextSharp.dll to generate pdfs ,this will get from sourceforge.net , and reference to your project , then write code like this
Document dc = new Document(PageSize.LETTER);
dc.NewPage();
|
|
|
|
|
Thanks, I give it a try
|
|
|
|
|
Just my 2c, I found itextSharp very easy to implement.
|
|
|
|
|
Hello everybody,
I have a file where some application is storing some values. I want to access to this file in read mode but when I try to open the file I have always the message that the process can't acces the file because it is being used by other application.
If I try to open this file with Microsoft excel I have an alert that says that the file is user by other application but I am allowed to open the file in read mode only.
How can I access the file with .net and advoid the exception if it is possible?
Thanks in advance
|
|
|
|
|
cidmi.dovic wrote: I try to open the file I have always the message that the process can't acces the file because it is being used by other application
Can you please post the code used, here ?
Found my answer helpful? Then vote for it. "A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
FileInfo file = new FileInfo(ConfigurationSettings.AppSettings["FilePath"]);
using (FileStream fStream = file.OpenRead())
{
}
|
|
|
|
|
Try this:
FileInfo file = new FileInfo(ConfigurationSettings.AppSettings["FilePath"]);
using (FileStream fStream = file.Open(FileMode.Open, FileAccess.Read, FileShare.Read))
{
}
|
|
|
|
|
Yes, it works.
A lot of thanks!!!
|
|
|
|
|
If someone answers your question, vote their answer so the rest of us don't waste time trying to give you the same answer.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Well, I'll try to copy the file and open this new file.
|
|
|
|
|
The other application that's writing to the file may have set the sharing to None, meaning no other app can open the file for any reason as long as the first app has it open.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
hi all..
i have a problem as u can guess...i have two forms..in Form1 i have a datagridview and it gets datas from my database..i added datas to database from Form2 everything is ok till here but when i added data and closed the Form2 then i cant see the new row in my datagridview...i want to see new row when i finished my adding...to see the new row i used the codes Form2 closedevent
Form1 frm1=new Form1();
frm1.datagridview1.Refresh();
but still i cant see the new row that i have just added..what can i do to see it ??
|
|
|
|
|
try this:
in form1:
form2 f2=new form2();
f2.showdialog();
frm1.datagridview1.Refresh();
|
|
|
|
|
hi man
thanks for the reply...so which event i will write that code??
i used it in Form1_Load but it didnt work and directly my Form2 was opened not Form1
do u have any other suggestion ?
|
|
|
|
|
create button1
and put it in button1_Click(....)
|
|
|
|
|
i used that codes in the button that i use it to open Form2
but still i didnt get the result i wished...and i used the same codes in the button tht i have Form2 that i use it to close Form2 but it didnt work also
|
|
|
|
|
try this:
in form1:
form2 f2=new form2();
f2.showdialog();
frm1_load(...);<<<<<<<<<<<<<<<<<<<<
|
|
|
|
|
Not a good idea - it ties the design of form1 to the design of form2. I.e. if you replace the datagrid view in form1 with some other construct then it needs changes to form2 as well. This defeats one of the aims of an OOP language.
A better approach is to create an event in form2 which you subscribe to in form1. Then form2 internally needs to know nothing about who is using the data, it just signals "my data has changed" and all forms that subscribe to the event then update themselves appropriately.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Hello,
for solving you're problem, you can use delegates.
Take a look here.
Cheer's,
Alex Manolescu.
|
|
|
|
|
so how i can use delegates here ??
i mean which parameter i can send to the method ??
i will be happy if u help me about it ?
|
|
|
|
|
hi,
I've made a small project for you.
Supose you have a DataGridView control with 1 column.
The value we need to pass to the AddRow method is the string info.
Form1:
- contains: a DataGridView and a Button
public partial class Form1 : Form
{
public delegate void InsertIntoDGV(string info);
public static InsertIntoDGV idv;
public Form1()
{
InitializeComponent();
idv = new InsertIntoDGV(AddRow);
}
public void AddRow(string info)
{
dataGridView1.Rows.Add(new object[] { info });
}
private void button1_Click(object sender, EventArgs e)
{
new Form2().ShowDialog();
}
}
And now Form2:
- contains a TextBox and a Button.
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form1.idv(textBox1.Text);
}
}
Hope this helps!
Cheer's,
Alex Manolescu.
|
|
|
|
|
Did it solved you're problem man?
At least answer if you post a problem!
|
|
|
|
|
Dear Expert I have usercontrol to create a new record/edit an existing record. The usercontrol have two constructors. one for "Create new record " and other for Load existing record for edit. When page have id in query string then load existing record for edit constructor execute otherwise create new rocord constructor executes.
The following is the code behind of usercontrol ("ContractControl")
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace DynamicForms.Portal.Controls
{
public partial class ContractControl : System.Web.UI.UserControl, IContract
{
protected bool _createMode;
public ContractControl()
{
_createMode = true;
this.Save += new EventHandler(ContractControl_Save);
this.Cancel += new EventHandler(ContractControl_Cancel);
}
public ContractControl(IContract contract)
{
_createMode = false;
this.Save += new EventHandler(ContractControl_Save);
this.Cancel += new EventHandler(ContractControl_Cancel);
ID = contract.ID;
Client_ID = contract.Client_ID;
Name = contract.Name;
}
protected void Page_Load(object sender, EventArgs e)
{
}
#region IContract Members
public Guid ID
{
get
{
return Guid.NewGuid();
}
set
{
ID = value;
}
}
public string Name
{
get
{
return NameTextBox.Text;
}
set
{
try
{
NameTextBox.Text = value;
}
catch
{
}
}
}
#region Public Events
public event EventHandler Save;
public event EventHandler Cancel;
#endregion
#region Default Public Event handelrs
protected void ContractControl_Save(object sender, EventArgs e)
{
//Do Nothing
}
protected void ContractControl_Cancel(object sender, EventArgs e)
{
//Do Nothing
}
#endregion
protected void SaveButton_Click(object sender, EventArgs e)
{
Save(this, e);
}
protected void CancelButton_Click(object sender, EventArgs e)
{
Cancel(this, e);
}
}
Following code execute on pageload of my webpage where I used above usercontrol
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.Params["id"] != null && Request.Params["id"].Length > 0)
{
Controllers.ContractController _controller=new Controllers.ContractController();
Controls.IContract _contract= _controller.Load(new Guid(Request["id"].ToString()));
ContractControl1 = new Controls.ContractControl(_contract);
}
else
{
ContractControl1 = new DynamicForms.Portal.Controls.ContractControl();
}
}
}
The new record is being created successfully. But editing throws following error
"An unhandled exception of type 'System.StackOverflowException' occurred in MyProject.web.DLL"
I am waiting your suggestions please.
|
|
|
|