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


C# TextBox.GetFirstCharIndexFromLine方法代码示例

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


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

示例1: GetTextLocation

		TextLocation GetTextLocation(TextBox textBox, int offset)
		{
			int line = textBox.GetLineFromCharIndex(offset);
			int col = offset - textBox.GetFirstCharIndexFromLine(line);
			return new TextLocation(line + 1, col + 1);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:6,代码来源:CSDemo.cs

示例2: GetOffset

		int GetOffset(TextBox textBox, AstLocation location)
		{
			return textBox.GetFirstCharIndexFromLine(location.Line - 1) + location.Column - 1;
		}
开发者ID:ThomasZitzler,项目名称:ILSpy,代码行数:4,代码来源:MainForm.cs

示例3: GetOffset

		int GetOffset(TextBox textBox, TextLocation location)
		{
			// TextBox uses 0-based coordinates, TextLocation is 1-based
			return textBox.GetFirstCharIndexFromLine(location.Line - 1) + location.Column - 1;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:5,代码来源:CSDemo.cs

示例4: GenerateSQLFile

        /// <summary>
        /// Generates a SQL File and saves it in the SQL folder.
        /// </summary>
        /// <param name="fileStart">The beginning of the fileName</param>
        /// <param name="fileName">FileName after fileStart (usually entry & name)</param>
        /// <param name="tb">The textbox to create from (text)</param>
        private void GenerateSQLFile(string fileStart, string fileName, TextBox tb)
        {
            // Save location / path
            string path = @".\SQL\" + fileStart + fileName + ".SQL";

            // Checks if the path file exists
            if (File.Exists(path))
            {
                // Creates a messagebox with a warning
                DialogResult dr = MessageBox.Show("File already exists.\n Replace it?", "Warning ...", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                // If the feedback is no, stop the program from running
                if (dr == DialogResult.No)
                {
                    return;
                }
            }
            else
            {
                DialogResult dr = MessageBox.Show("SQL folder does not exist. \nAutomatically create one for you?", "The folder 'SQL' could not been found.", MessageBoxButtons.YesNo, MessageBoxIcon.Error);

                if (dr == DialogResult.Yes)
                {
                    Directory.CreateDirectory(@".\SQL\");
                }
                else
                {
                    return;
                }
            }

            // Checks if textbox is empty OR fileName is empty
            if (tb.TextLength == 0 || fileName == string.Empty)
            {
                return;
            }

            // StreamWriter is used to write the SQL.
            StreamWriter sw = new StreamWriter(path);

            // Puts every line of the selected textbox in an array.
            int lineCount = tb.GetLineFromCharIndex(tb.Text.Length) + 1;

            for (var i = 0; i < lineCount; i++)
            {
                int startIndex = tb.GetFirstCharIndexFromLine(i);

                int endIndex = (i < lineCount - 1) ?
                    tb.GetFirstCharIndexFromLine(i + 1) : tb.Text.Length;

                sw.WriteLine(tb.Text.Substring(startIndex, endIndex - startIndex));
            }

            // Closes the StreamWriter.
            sw.Close();
        }
开发者ID:Heitx,项目名称:Manti-TC,代码行数:62,代码来源:FormMain.cs


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