当前位置: 首页>>代码示例>>C#>>正文


C# RichTextBox.GetCharIndexFromPosition方法代码示例

本文整理汇总了C#中System.Windows.Forms.RichTextBox.GetCharIndexFromPosition方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.GetCharIndexFromPosition方法的具体用法?C# RichTextBox.GetCharIndexFromPosition怎么用?C# RichTextBox.GetCharIndexFromPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.RichTextBox的用法示例。


在下文中一共展示了RichTextBox.GetCharIndexFromPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Column

        public static int Column(RichTextBox e, int index1)
        {
            int correction = GetCorrection(e, index1);
            Point p = e.GetPositionFromCharIndex(index1 - correction);

            if (p.X == 1)
                return 1;

            p.X = 0;
            int index2 = e.GetCharIndexFromPosition(p);

            int col = index1 - index2 + 1;

            return col;
        }
开发者ID:BrentKnowles,项目名称:YourOtherMind,代码行数:15,代码来源:CursorPositionclass.cs

示例2: UpdateLineNumbers

        void UpdateLineNumbers(RichTextBox lineNumbers, RichTextBox thisRtb)
        {
            //getLinefromCharindex isn't the same as line number when dealing with wordwrap
               // string[] textLines = thisRtb.Text.Split('\n');
            int topLine = lineFromCharIndex(thisRtb.Text, (thisRtb.GetCharIndexFromPosition(new Point(0,0))));

            int bottomLine = thisRtb.GetLineFromCharIndex(thisRtb.GetCharIndexFromPosition(new Point(1, thisRtb.Height)));

            int currentLine = 0;
            lineNumbers.Text = "";
            int lastLine = 0;

            for (int i = topLine; i <= bottomLine; i++)
            {

                currentLine = lineFromCharIndex(thisRtb.Text, thisRtb.GetFirstCharIndexFromLine(i-1));

                if (lastLine != currentLine)
                {
                    lineNumbers.AppendText(currentLine + "");
                    lastLine = currentLine;
                }

                lineNumbers.AppendText("\n");
            }

            lineNumbers.SelectAll();
            lineNumbers.SelectionAlignment = HorizontalAlignment.Right;
        }
开发者ID:blindsight,项目名称:CSSControl,代码行数:29,代码来源:EditorForm.cs

示例3: ReverseHighlightText

			}

		}

		public static void ReverseHighlightText( RichTextBox Rtx , TreeView Tnc , System.Drawing.Point Pt , ref StatusBar SBar )
		{
			int i = 0;
			TreeNode PNode = null;
			int CharIndex = 0;
			int [] intArray;
			int ModeX = 0, ModeY = 0;
			ArrayList aList = new ArrayList();

			CharIndex = Rtx.GetCharIndexFromPosition( Pt );

			if( CharIndex < 167 ) return;

			ModeX = CharIndex / 78;
			ModeY = CharIndex - ( ModeX * 78 );
			ModeY -= 11;
			if( ModeY > 48 )
			{
				ModeY -= 48;
				CharIndex = ModeX * 78 + 11 + ModeY * 3 - 1;
			}

			for( i = 1; i < Tnc.Nodes.Count; i ++ )
			{
				PNode = Tnc.Nodes[ i ];
				aList.Add( PNode );
				if( PNode.Nodes.Count > 0 )
					AddNodeToTheList( PNode , ref aList );
			}

			for( i = 0; i < aList.Count; i ++ )
			{
				PNode = ( TreeNode ) aList[ i ];

				try
				{
					intArray = ( int [] ) PNode.Tag;
					if( intArray != null )
					{
						if( ( CharIndex >= intArray[2] ) && ( CharIndex <= ( intArray[ intArray.Length - 4 ] + intArray[intArray.Length - 3 ] ) ) && ( PNode.Nodes.Count == 0 ) )
						{
							Tnc.SelectedNode = PNode;
							HighlightText( Rtx , PNode , ref SBar );
							return;
						}
					}
				}
				catch( Exception Ex )
				{
					MessageBox.Show( ReturnErrorMessage( Ex ) );
开发者ID:dbose,项目名称:raagahacker,代码行数:54,代码来源:MyFunctions.cs

示例4: FindDataSizeAndLength

			return Tmp;
		}


		public static bool FindDataSizeAndLength( RichTextBox Rtx , int X1 , int X2 , ref int ClickedIndex )
		{
			int CharIndex = 0;
			int ModeX = 0, ModeY = 0;
			System.Drawing.Point Pt = new System.Drawing.Point( X1 , X2 );

			CharIndex = Rtx.GetCharIndexFromPosition( Pt );

			if( CharIndex < 167 ) 
			{
				ClickedIndex = -1;
				return false;
			}

			CharIndex -= 166;
			ModeX = CharIndex / 78;
			ModeY = CharIndex - ( ModeX * 78 );
			if( ModeY > 48 )
			{
				ClickedIndex = -1;
				return false;
			}

			ModeY /= 3;
开发者ID:dbose,项目名称:raagahacker,代码行数:28,代码来源:MyFunctions.cs

示例5: GetCurrentPos

 public static void GetCurrentPos(RichTextBox rtfMain, ref int line, ref int col)
 {
     Point pt;
     int index;
     index = rtfMain.SelectionStart;
     line = rtfMain.GetLineFromCharIndex(index);
     pt = rtfMain.GetPositionFromCharIndex(index);
     pt.X = 0;
     col = index - rtfMain.GetCharIndexFromPosition(pt);
     line ++;
     col ++;
     return;
 }
开发者ID:caesay,项目名称:Asn1Editor,代码行数:13,代码来源:FormConvertData.cs


注:本文中的System.Windows.Forms.RichTextBox.GetCharIndexFromPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。