|
Hi,
ListBox (and ComboBox) have two find methods: FindString and FindStringExact;
and these have an overload that takes a starting index.
If interested I suggest you look it up in MSDN...
But before changing all your code, give it a try with my first suggestion
(and tell us the new speed).
|
|
|
|
|
|
Hi,
I may suggest that (considering you are just manipulating text) you should rely on the Find() method of the rtf :
int positionFound=Find(text,startPosition,endPosition,options)
I think you should use 'Find' to get the position of the '[END]' tag and not use a loop , as in your exemple.
Hope it helps
|
|
|
|
|
i m not getting you, can you explain little bit more??
"I think you should use 'Find' to get the position of the '[END]' tag and not use a loop , as in your exemple"
but how can i know the lenght of between [ID] and [End]???
Becoming Programmer...
|
|
|
|
|
Sure...
* assuming you have a form with 2 rtf , and a button to copy from richTextBox1 to richTextBox2
* assuming you only deal with text
the code below should do the trick in no time
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace rtfTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
richTextBox1.Text = "[ID] = 0000\nlines\n[END]\n[ID] = 1234\nlines for 1234\n[END]";
}
private void button1_Click(object sender, EventArgs e)
{
string beginTag = "[ID] = 1234";
string endTag = "[END]";
int startPosition = richTextBox1.Find(beginTag);
if (startPosition >= 0)
{
startPosition = startPosition + beginTag.Length+1;
int endPosition = richTextBox1.Find(endTag,startPosition,RichTextBoxFinds.MatchCase);
if (endPosition > startPosition)
richTextBox2.Text = richTextBox1.Text.Substring(startPosition , endPosition - startPosition );
}
}
}
}
|
|
|
|
|
yep thats also good way, i like, thanks
Becoming Programmer...
|
|
|
|
|
Hi,
Sorry, If I have posted this query to a wrong group!
I'm facing an issue with C# project. I use VS 2005 express edition.
I was developing a C# project and had couple of UI controls that I had placed
using UI editor. Everything was fine but now I can't view the "UI designer" now.
If I run the project I do get the UI that I had designed but cant edit it now?
How can I see the disigner again?
Thanks
Vikas
|
|
|
|
|
Hi,
Try to close the form and Rebuild Solution..and if the rebuild has succeeded..try to open your form again,sometimes i get the same problem but when i do that my UI designer can be view again
Kind Regards,
Tomi
|
|
|
|
|
I tried but still I can't see the form design! I guess, I will have to port the entire code into a new project now
|
|
|
|
|
Hi there .
I think , it's better to check your reference files.
Maybe you missed one of your reference . if it is , remove you reference from reference list and add it to your project reference again , and then Rebuild your solution or project , what ever as you want .
DMASTER
|
|
|
|
|
Hello,
What you can try:
In your project explorer, rightclick the Form or usercontrol you can not edit and change the "buildaction" to an other setting and then back to "compile" (I have not the english version and only 2003 so I don't know the exact names).
Then make a rebuild.
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hi, Ok I know why this is happening but pls tell me whats wrong in doing this?
1. My form is like this: Everything is proper and I can view the designer
<br />
<br />
public partial class Form1 : Form<br />
{<br />
}<br />
2. I need to have a special control class say MyPictureBox derived from PictureBox so added the code as follows in file Form1.cs:
<br />
<br />
public class MyPictureBox : System.Windows.Forms.PictureBox<br />
{<br />
}<br />
<br />
public partial class Form1 : Form<br />
{<br />
}<br />
Thats it: Now If I try to open the designer I get the error:
<br />
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes. <br />
<br />
The service System.Windows.Forms.Design.ISelectionUIService already exists in the service container. Parameter name: serviceType <br />
Hide <br />
<br />
at System.ComponentModel.Design.ServiceContainer.AddService(Type serviceType, Object serviceInstance, Boolean promote)<br />
at System.ComponentModel.Design.ServiceContainer.AddService(Type serviceType, Object serviceInstance)<br />
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IServiceContainer.AddService(Type serviceType, Object serviceInstance)<br />
at System.Windows.Forms.Design.ComponentDocumentDesigner.Initialize(IComponent component)<br />
at System.ComponentModel.Design.DesignerHost.AddToContainerPostProcess(IComponent component, String name, IContainer containerToAddTo)<br />
at System.ComponentModel.Design.DesignerHost.Add(IComponent component, String name)<br />
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type componentType, String name)<br />
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)<br />
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)<br />
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)<br />
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)<br />
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)<br />
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host) <br />
Afterwards, I will not be able to view the original designer but I think the designer related to MyPictureBox which is blank.
But if I put the body of MyPictureBox after the body of Form as shown below, everything is fine!
<br />
<br />
public partial class Form1 : Form<br />
{<br />
}<br />
<br />
public class MyPictureBox : System.Windows.Forms.PictureBox<br />
{<br />
}<br />
Pls let me know what is the procedure in adding a derived UI control class?
Thanks
|
|
|
|
|
Hello,
The Problem is that both classes have design support.
It is not good practice to but them all in one file.
If you put the picturebox in a special file you will also be able to open it over the designer.
All the best,
Martin
|
|
|
|
|
Thank you Martin and others who gave quick answers!
I created another file and things are pretty nice now!
Help is really appreciated
|
|
|
|
|
Hello Every body,
I am new with crystal reports. I want to generate report for those employees whose age is more than 50 yrs.
But I am not able to do so .It is showing all the records.
I had added an crystal report in my project.
I link it with the database through wizard only,
On form1 it had inserted an crystal report viewer. on the load event of the form1 I had used the following code but it is use less.
SqlConnection Connection = new SqlConnection("server='server1'; user id='sa'; password='admin'; database='employee'");
SqlCommand myCommand = new SqlCommand("SELECT * from companyEmp where age < '50'");
myCommand.Connection = Connection;
myCommand.CommandType = CommandType.Text;
SqlDataAdapter DA = new SqlDataAdapter();
DA.SelectCommand = myCommand;
DataSet DS = new DataSet();
DA.Fill(DS);
crystalReportViewer1.SetDataSource(DS.Tables[0]);
crystalReportViewer1.ReportSource = objNewReport;
But it is still showing all the record of companyEmp.
Regards,
rahul saini
|
|
|
|
|
monuSaini wrote: SqlCommand myCommand = new SqlCommand("SELECT * from companyEmp where age < '50'");
U just need:
SqlCommand("SELECT * from companyEmp where age < 50");
'50' -> type string
50 -> int
Regard,
Edwin
|
|
|
|
|
Hello Edwin,
Thanks for ur rply.
But still same problem.
It is showing all the records.
If I am using only this
crystalReportViewer1.ReportSource = NewReport;
then also it is showing all the records.
Rregards,
rahul saini
|
|
|
|
|
may i know the data type of age in your database?
Regards,
Tomi
|
|
|
|
|
Hello Tomi,
Thanks for ur rply.
Its int.
Regards,
rahul saini
|
|
|
|
|
Hi Rahul,
I wonder if u want to show the data if the age is above 50 right?
if u use query:
SELECT * FROM Your_Table Where age < 50
u got an output data age below 50, if u want to show the data where age is more than 50 than u must change your query into :
SELECT * FROM Your_Table WHERE age > 50
i try to my query analizer thats work
Regard,
Tomi
|
|
|
|
|
TomiEdy wrote: if u use query:
SELECT * FROM Your_Table Where age < 50
u got an output data age below 50, if u want to show the data where age is more than 50 than u must change your query into :
SELECT * FROM Your_Table WHERE age > 50
I think U right Tomi, maybe U must check your query Rahul
Regard,
Edwin
|
|
|
|
|
Thank You Edwin
Regard,
Tomi
|
|
|
|
|
SqlDataAdapter adapter = new SqlDataAdapter(yourQuery, conn);
DataSet ds = new DataSet();
DataTable dt = new DataTable("tablename");
adapter.Fill(dt);
ds.Tables.Add(dt);
ds.WriteXml("C:\text.xml");
Then On your crystal report Database Fields:
change your dataset with "text.xml"
If U have finish it, then create a dataset with your query, then change the code like this:
SqlDataAdapter adapter = new SqlDataAdapter(yourQuery, conn);
DataSet ds = new DataSet("YourDataSet");
DataTable dt = new DataTable("tablename");
adapter.Fill(dt);
ds.Tables.Add(dt);
ReportDocument rd = new ReportDocument();
rd.SetDataSource = ds;
crystalReportViewer1.ReportSource = rd;
Regard,
Edwin
|
|
|
|
|
Hello Edwin,
When i m writing the xml it is giving me following error.
ds.WriteXml("C:\text.xml");
Illegal characters in path.
Regards,
rahul saini
|
|
|
|
|
ds.WriteXml("C:\text.xml");
-- \t is the character code for a tab. You need to escape your backslashes by... using another backslash.
ds.WriteXml("C:\\text.xml");
|
|
|
|