We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Find & copy paste - DataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

16379 Jul 14,2004 06:57 AM UTC Jul 15,2004 12:30 PM UTC WinForms 7
loading
Tags: GridControl
Satish
Asked On July 14, 2004 06:57 AM UTC

Clay, Please find below are my queires, 1. Find & Replace is having problem in RichText Cell (InplaceRichText Editor Cell). It works fine when user clicks Replace All, if user want to replace one by one cell then the data is getting deleted (from that cell) after replacing the Text. So how to solve this? 2. I have assigned int datatye of one of my cell. Now if the user copy''s some text and paste on that cell, the system through''s the error and closes the application becuase the cell holds only integer or numeric values''s. So in this sitution how do we handle the validation for only numeric fields??? Thanks Satish

Administrator [Syncfusion]
Replied On July 14, 2004 07:22 AM UTC

1) If you send a sample project showing how you are trying to do Find & Replace, and what problem you are having, we can try to suggest something. I suspect it will take some special coding to handle it as our base support has no support for searching for a text string in an RTF string which is probably what is happening in this case. 2) To validate cells when you are pasteing text, you handle the grid.Model.PasteCellText event. The event args will have the row and column to be pasted along with the text. You should set e.Cancel = true if you do not want the text to be pasted.

Satish
Replied On July 15, 2004 06:09 AM UTC

Hi Clay, For a Point No. 1. Please find the attached sample. Now clear is not happening but the richtext box is showing the junk character. We have progressed little bit on the autosize of the RichText but not fully. I would request you to hightlight on the Autosize using sample application would be appricated. Thanks Satish >1) If you send a sample project showing how you are trying to do Find & Replace, and what problem you are having, we can try to suggest something. I suspect it will take some special coding to handle it as our base support has no support for searching for a text string in an RTF string which is probably what is happening in this case. > >2) To validate cells when you are pasteing text, you handle the grid.Model.PasteCellText event. The event args will have the row and column to be pasted along with the text. You should set e.Cancel = true if you do not want the text to be pasted. RichTextInPlaceCellContol_8812.zip

Administrator [Syncfusion]
Replied On July 15, 2004 07:08 AM UTC

Try adding this override to the renderer class to see if it will take care of this problem.
public override bool ReplaceText(string find, string replace, int rowIndex, int colIndex, GridFindTextOptions options, bool bSetCell)
{
	bool wholeCell = (options & GridFindTextOptions.MatchWholeCell) != 0;
	bool matchCase = (options & GridFindTextOptions.MatchCase) != 0;

	GridStyleInfo style = Grid.Model[rowIndex, colIndex];
	string text = style.FormattedText;
	CultureInfo culture = style.GetCulture(true);

	string text2 = text;
	if (!matchCase)
	{
		find = find.ToLower(culture);
		text2 = text.ToLower(culture);
	}

	bool found = false;
	if (wholeCell)
	{
		found = find.Equals(text2);
		if (found)
		{
			if (bSetCell)
			{
				CurrentCell.MoveTo(rowIndex, colIndex);
				CurrentCell.BeginEdit();
				CurrentCell.Renderer.ControlText = replace;
			}
			else 
			{
				Grid.Model[rowIndex, colIndex].FormattedText = replace;
			}
		}
	}
	else
	{
		int index = text2.IndexOf(find.ToString());
		if (index != -1)
		{
			found = true;
			StringBuilder sb = new StringBuilder();
			if (index > 0)
				sb.Append(text.Substring(0, index));
			sb.Append(replace);
			index += find.Length;
			int index2 = -1;
			do
			{
				text2 = text.Substring(index);
				if (!matchCase)
					text2 = text2.ToLower(culture);
				index2 = text2.IndexOf(find.ToString());
				if (index2 != -1)
				{
					if (index2 > 0)
						sb.Append(text.Substring(index, index2));
					sb.Append(replace);
					index += index2 + find.Length;
				}
			}
			while (index2 != -1);
			if (index < text.Length)
				sb.Append(text.Substring(index));
			if (bSetCell)
			{
				CurrentCell.MoveTo(rowIndex, colIndex);
				CurrentCell.BeginEdit();
				//CurrentCell.Renderer.ControlText = sb.ToString();
				activeRichTextBox.Rtf = sb.ToString();
			}
			else 
			{
				Grid.Model[rowIndex, colIndex].FormattedText = sb.ToString();
			}
		}
	}
        return found;
	
	//return base.ReplaceText (find, replace, rowIndex, colIndex, options, bSetCell);
}
I do not have any further ideas on autosizing RTF. Exactly what is not working for you?

Administrator [Syncfusion]
Replied On July 15, 2004 07:38 AM UTC

Here''s is your sample back with the code from above tweaked a little more to handle some special cases. InPlaceRTF_9286.zip

Satish
Replied On July 15, 2004 11:45 AM UTC

Clay, Thank. When I clicked Esc i should able to close the Find & Replace window. How do we achive this? Thanks Satish >Here''s is your sample back with the code from above tweaked a little more to handle some special cases. > >InPlaceRTF_9286.zip > >

Satish
Replied On July 15, 2004 12:26 PM UTC

Hi Clay, I used the following for auto resize for richtext but still not proper output. Can you please suggest how to achive this. Thanks Satish We wrote sepearte method called SetHeight will will set the height after all the editing is over in the richtext. ------------------------------------------- /// /// Set''s the Row Height /// private int SetHeight(string rtfText) { RichTextBox activeRichTextBox = new RichTextBox(); activeRichTextBox.Rtf=rtfText; int selectionFontHeight = activeRichTextBox.SelectionFont.Height; int height = activeRichTextBox.GetPositionFromCharIndex(activeRichTextBox.TextLength).Y + selectionFontHeight / 2; int selLength = activeRichTextBox.SelectedText.Length; int startIndex = activeRichTextBox.SelectionStart; int endIndex = startIndex + activeRichTextBox.SelectedText.Length; int lastLine = activeRichTextBox.GetLineFromCharIndex(activeRichTextBox.TextLength); int sellastLine = activeRichTextBox.GetLineFromCharIndex(endIndex); int fontSize = 0; for(int i = 0;i<=activeRichTextBox.TextLength;i++) { if(i < startIndex || i > endIndex ) { activeRichTextBox.Select(i,1); if(activeRichTextBox.SelectionFont.Height > fontSize) { fontSize = activeRichTextBox.SelectionFont.Height; } } } activeRichTextBox.Select(startIndex,selLength); if(fontSize <= selectionFontHeight) if(lastLine == sellastLine) height += selectionFontHeight; else height += selectionFontHeight/2; else height += fontSize; //+ selectionFontHeight/2; //height = height + selectionFontHeight; return height; } --------------------------------------------- >Clay, >Thank. When I clicked Esc i should able to close the Find & Replace window. How do we achive this? >Thanks >Satish > >>Here''s is your sample back with the code from above tweaked a little more to handle some special cases. >> >>InPlaceRTF_9286.zip >> >>

Administrator [Syncfusion]
Replied On July 15, 2004 12:30 PM UTC

You can try replacing the GridFindReplaceDialogSink with this code.
public GridFindReplaceDialogSink GridFindReplaceDialogSink
{
	get
	{
		if (findReplaceDialogSink == null)
		{
			findReplaceDialogSink = new GridFindReplaceDialogSink(gridDataBoundGrid1);
			Button close = null;
			foreach(Control c in GridFindReplaceDialog.Instance.Controls)
			{
				if(c.Text == "Close")
				{
					close = c as Button;
				}
			}
			if(close != null)
				GridFindReplaceDialog.Instance.CancelButton = close;
		}
		return findReplaceDialogSink;
	}
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;