|
I'm using VS2005 with MSAcsess and MS ReportViewer to genearate a report. It work perfectly in my development environment. When i try to deploy the application to Virtual PC with a clean environment, it work fine. The application will hang when user open the report form and close and reopen (sometime happen on the third time)again the report form.
Below is the code. And also i found out if user close the form in PrintLayout Mode. I must cancel the report rendering in form close event. this.reportViewer1.CancelRendering(5000); Else the program will hanged forever when user click PrintLayout button.
<br />
FormReport frm = new FormReport();<br />
this.Cursor = Cursors.WaitCursor;<br />
try<br />
{<br />
frm.ShowReport(sqlStatement + frm2.QueryString + " " + order , reportName);<br />
frm.ShowDialog();<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message); <br />
}<br />
finally<br />
{<br />
this.Cursor = Cursors.Default;<br />
}<br />
<br />
private void ShowReport(string reportName, ReportsDS reportDS)<br />
{<br />
if (reportDS.Report.Rows.Count < 1)<br />
{<br />
MessageBox.Show("No records found. Please import data into system.");<br />
this.Close();<br />
}<br />
ReportDataSource reportDataSource = new ReportDataSource();<br />
reportDataSource.Name = "ReportsDS_Report";<br />
reportDataSource.Value = reportDS.Report;<br />
this.reportViewer1.LocalReport.ReportEmbeddedResource = reportName;<br />
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource);<br />
this.reportViewer1.RefreshReport();<br />
}<br />
<br />
private void FormReport_FormClosing(object sender, FormClosingEventArgs e)<br />
{<br />
try<br />
{<br />
this.reportViewer1.CancelRendering(5000);<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message); <br />
}<br />
}<br />
<br />
<br />
|
|
|
|
|
Hi there,
I'm creating an application to securely record information typed in by the user.
A main window (let's call it 'A') with a large RTF box displays the text so far - this text box is read-only to preserve the integrity of previous entries, so no editing is allowed here.
When the user wants to post a new entry the they click a button and a new RTF box appears (call this one 'B') - into this the user can type or paste RTF compliant entries, when done, clicks "OK" and the contents of this RTF box (B) need to be added to the read-only main window (A).
I don't have a problem with the protection and getting stuff from B into A - however I have a major problem maintaining the RTF formatting when taking the contents of one RTF control and appending it to the contents of the other read-only version!
I don't want to save RTF from B to file and read that in to A as this will present the opportunity to subvert the process and add additional material. Likewise, I can make this work very reliably if I stick with plain text - but the moment I want to retain the RTF formatting it all gets very hard.
Any thoughts?
Kind regards,
John.
|
|
|
|
|
I suggest when you add some RTF text, you also add whatever commands are required
to return all text attributes to their neutral settings (i.e.
default font, not bold, not italic, black, etc) plus a new line;
as a result each consecutive piece of RTF will start from the same known situation.
Luc Pattyn
|
|
|
|
|
Luc,
That's kind of what I'm doing now, but I'd like to allow the users to use the full RTF formatting options open to them, including pasting in graphics.
Kind regards,
John.
|
|
|
|
|
I assume you have been trying to do something like:
rtfReadOnly.Rtf += rtfEdit.Rtf;
The problem is that you will be binding two complete rtf documents together. Which will end up with invalid rtf. You should read up on the rtf format as I think you will have you modify the raw rtf strings of both rtfs before binding them together.
By this I mean removing the rtf header from the rtf doc you are trying to add and the trailing '}' from the readonly rtf.
|
|
|
|
|
I managed to get it to work. Try this:
string rtf1 = rtfReadOnly.Rtf.TrimEnd("}\r\n".ToCharArray());
string rtf2 = rtfEdit.Rtf.TrimStart(@"{\\rtf1".ToCharArray());
rtfReadOnly.Rtf = rtf1 + rtf2;
|
|
|
|
|
That's cool - I'll have a play with that over the weekend.
I'm glad that it isn't just me and this actually is quite hard!
Kind regards,
John.
|
|
|
|
|
hellow everyone
I want to create an excel file using c# meaning that I want to
write into the cell of the table of excel
can someone send me an example of
how I connect C# to excel?
thank u
|
|
|
|
|
barak160487 wrote: I want to create an excel file using c#
Perhaps you could generate a .csv [^] file which is readable by Excel?
/ravi
|
|
|
|
|
http://www.codeproject.com/office/csharp_excel.asp
http://www.thescripts.com/forum/thread224584.html
-- modified at 2:26 Friday 26th January, 2007
|
|
|
|
|
thank u it helped
|
|
|
|
|
On a usercontrol, is there an easy way to suspend all event handling on the control and all child controls? I don't want my event handling to keep firing as I set the form up, rather I just want to call a set of calculating/formatting functions just once in Load(), and then have all the events (which call the calculating/formatting functions) start firing. Right now I have an if statement in each event that ties to a boolean that I set when I want events to start working, but it seems like there might be an easier way.
Any suggestions?
|
|
|
|
|
How about using one method to remove the handlers and another to add. Then you're swichting them on and off in just two places.
i.e.
private void RemoveHandlers()
{
button1.Click -= new EventHandler(clickHandler);
----
}
private void AddHandlers()
{
button1.Click += new EventHandler(clickHandler);
----
}
|
|
|
|
|
I could look this up and figure it out, but what exactly is the difference between casting like (int) and Convert.ToInt32(); I am converting database columns and it throws an error if I use the first but is fine with the second.
I would like to know really what the differences are.
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
A couple things:
An exception will not be thrown if the conversion of a numeric type results in a loss of precision (that is, the loss of some least significant digits). However, an exception will be thrown if the result is larger than can be represented by the particular conversion method's return value type.
and...
Some of the methods in this class take a parameter object that implements the IFormatProvider interface. This parameter can supply culture-specific formatting information to assist the conversion process.
Among other things, casting doesn't always work:
string foo="123";
int i=(int)foo; // That doesn't work
int j=Convert.ToInt32(foo); // This works.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
The latter part of your post actually was what I was hitting at, I am trying to understand why this behaviour occurs. I understand the who larger smaller conversion capabilities.
Thanx,
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
There has to be an ISA relationship between the classes before casting works.
i.e. If int inherits string then the follwoing works:
string foo="123";
int i=(int)foo;
See the Int32 inheritance heirarchy:
System.Object
System.ValueType
System.Int32
|
|
|
|
|
I'll just add - you should use int.TryParse if you have any doubts about the conversion. This requires that you have a string, or that ToString gives you the representation you're hoping for.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Please can somebody give me a useful link od discription how to record and immediate show a stream from a webcam or from a camcorder. I have tried with windows media encoder but this way is too slow
thx
|
|
|
|
|
Firstly, wrong forum, this is for C# specific questions.
Unless you fork out big bucks for specialised hardware you're not going to be able to do this, trust me on this, I've tried, the smallest latency I managed was 2 seconds and someone who spent several years doing this kind of stuff was impressed with it.
I have no idea what I just said. But my intentions were sincere.
Poore Design
|
|
|
|
|
When I start my app, any relative paths ("subfolder\filename.exe") are referenced from the directory the exe is located in. After I select a file in the file open dialog though, the folder of the selected file is used instead. How can I reset the default starting path back to the folder where my app was launched from?
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Well, you could use the GetCurrentDirectory[^] method to get the current directory just before you open the dialog, then call SetCurrentDirectory[^] afterward to reset it.
But, if your code is written properly, you should never have to worry about this. This means your code shoud be written to use fully qualified path names in all cases, and not rely, at all, on whatever the current directory is.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Would that be done by calling GetCurrentDirectory at app start and saving the value to combine for creating absolute paths at runtime, or is there a different static method provided in the framework that already does so?
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
YOu can get the path back to the directory that the .EXE was started from by using Application.StartupPath . If you have files in the same folder, or any subfolder, you can build your fully qualified names from that.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello,
Dave Kreskowiak wrote: YOu can get the path back to the directory that the .EXE was started from by using Application.StartupPath.
Is there a designtime support for that?
Means, all the other ways (apart from System.Inviroment.CurrentDirectory) brougt me an obscure path at design time.
I needed this for a costum designed property.
All the best,
Martin
|
|
|
|