|
Thanks! it is working
Sanjit.rajbanshi@wlinktech.com
|
|
|
|
|
|
You could also disable the button for as long as form2 is open.
Luc Pattyn
|
|
|
|
|
Hi,
We are retrieving records using Select Query from SQL Server Database tables. We want to create a html page and write the retrieved records using StreamWriter. How can we do that i.e. by using StreamWriter?
suggetions appreciated.
|
|
|
|
|
You asked this already the other day. I guess XML and CSS didn't work out for you.
We already showed you how to write with StreamWriter though. What is it you still don't understand about it?
|
|
|
|
|
the thing is just that i don't understand how to display the records (that are returned from a query) on any medium, be it XML or StreamWriter
|
|
|
|
|
If you tell us the medium that you are using to handle the results for your SQL query it could help us to guide you. Are you using DataSet and/or DataTable objects?
|
|
|
|
|
i'm using DataTable to hold the retrieved records.
|
|
|
|
|
From a DataTable object you can simply call the WriteXml(string filename) method to write to an XML file.
To write with a StreamWriter try:
using (StreamWriter sw = new StreamWriter(filename))
{
try
{
foreach (DataRow row in myDataTable)
{
sw.WriteLine(row["columnName1"]);
sw.WriteLine(row["columnName2"]);
sw.WriteLine("<body>");
sw.WriteLine("<otherformatting>" + row["columnName1"]);
sw.WriteLine("</body>")
}
}
catch (Exception er)
{
}
finally
{
sw.Close();
}
}
-- modified at 5:02 Friday 26th January, 2007
|
|
|
|
|
thanks for the suggestion.
i'll try it and if it still doesn't work for me i'll post another query for u to answer
|
|
|
|
|
Hi all. In Gridview, we can check whether grid contains rows or not by
Gridview1.Rows.Count .. Please tell me how to check against listbox.. Basically, I want to check whether listbox contains values or not. if it contains no value, then a message is displayed like NO RECORD FOUND. please help me in this regard.
|
|
|
|
|
Hello,
The ListBox class has a Property Items, which contains all the infos you need!
listBox1.Items.Contains(object); //search for an item
listBox1.Items.Count; //number of items
All the best,
Martin
|
|
|
|
|
I've written a program to access Text File , and filtered to a Data Table, then to Data View and Data Grid , and use GridStyle to display read only fields , but when I add a comments field in the GridStyle as a edited column , anytime I click the Data Grid field then push button to refresh , the marked read only fields show above the Data Grid , can anyone teach me how to correct this , thanks very much !
|
|
|
|
|
Oh Brainy Ones!
final_list=Convert.ToString(attribute_list.LastIndexOf(",",1,attribute_list.Length));<br />
All it returns is -1. If I change the value of the third argument of the function to 1,it returns -1.
The above code gives an exception
Argument Out of Range exception. Count must be positive and count must refer to a location within the string/array/collection.
i.e. count is the third argument
|
|
|
|
|
Well, it's hard to comment without knowing what is in attribute_list. It seems it doesn't contain a ,, and so the index is -1 ( indicating failure ).
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
i've checked the string and it does contain a ",", but the third argument of the LastIndexOf() still gives the exception.
Count must be positive and count must refer to a location within the string/array/collection.
the only time it doesn't give the exception is when v give 1 in its third argument.
any other suggestions??
|
|
|
|
|
First suggestion : use ToString instead of Convert.ToString
Second suggestion: change the 1 to 0, strings are 0 based. This means when you start with 1, the Length property is 1 bigger than what is allowable, hence the exception.
Third suggestion: if you want to search the entire string, don't specify a start and length at all, you can just give it the ',', and it will search the entire string.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
ThankYou
it worked
|
|
|
|
|
You need to use,
int index = attribute_List.LastIndexOf(",",attribute_List.Length - 1,attribute_List.Length);
Reason: LastIndexOf() method searches for the given string from right to left, so you need to specify the second parameter, ie. the startIndex from right to left. Hope the thing is clear.
|
|
|
|
|
At first I though WTF?! Then I tried it...
That is just weird. The documentation doesn't say it's right to left...
|
|
|
|
|
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.
|
|
|
|