1

私のrichtexBox1には以下の文がありますが、文がCreate tableで始まりセミコロンで終わる場合、各行の間に1行だけスペースを空け、行間を空けないでください。

結果:

ALTER TABLE "COURSE" DROP CONSTRAINT "CRSE_CRSE_FK";




ALTER TABLE "ENROLLMENT" DROP CONSTRAINT "ENR_STU_FK";

ALTER TABLE "ENROLLMENT" DROP CONSTRAINT "ENR_SECT_FK"; 

ALTER TABLE "ENROLLMENT" ADD CONSTRAINT "ENR_STU_FK" FOREIGN KEY ("STUDENT_ID") REFERENCES "STUDENT"("STUDENT_ID") ENABLE;

ALTER TABLE "ENROLLMENT" ADD CONSTRAINT "ENR_SECT_FK" FOREIGN KEY ("SECTION_ID") REFERENCES "SECTION"("SECTION_ID") ENABLE;


CREATE TABLE "COMP1" 
(   "EMPID" NUMBER, 
"EMPLNAME" VARCHAR2(20), 
"EMPFNAME" VARCHAR2(20), 
"DEPTNO" NUMBER, 
"MGRID" NUMBER, 
PRIMARY KEY ("EMPID") ENABLE
);

CREATE TABLE "COMP12" 
(   "EMPID" NUMBER, 
"EMPLNAME" VARCHAR2(20), 
"EMPFNAME" VARCHAR2(20), 
"DEPTNO" NUMBER, 
"MGRID" NUMBER, 
PRIMARY KEY ("EMPID") ENABLE
);

期待される結果

    ALTER TABLE "COURSE" DROP CONSTRAINT "CRSE_CRSE_FK";  

    ALTER TABLE "ENROLLMENT" DROP CONSTRAINT "ENR_STU_FK";

    ALTER TABLE "ENROLLMENT" DROP CONSTRAINT "ENR_SECT_FK"; 

    ALTER TABLE "ENROLLMENT" ADD CONSTRAINT "ENR_STU_FK" FOREIGN KEY ("STUDENT_ID") REFERENCES "STUDENT"("STUDENT_ID") ENABLE;

    ALTER TABLE "ENROLLMENT" ADD CONSTRAINT "ENR_SECT_FK" FOREIGN KEY ("SECTION_ID") REFERENCES "SECTION"("SECTION_ID") ENABLE;        

    CREATE TABLE "COMP1" 
    (   "EMPID" NUMBER, 
    "EMPLNAME" VARCHAR2(20), 
    "EMPFNAME" VARCHAR2(20), 
    "DEPTNO" NUMBER, 
    "MGRID" NUMBER, 
    PRIMARY KEY ("EMPID") ENABLE
    );

    CREATE TABLE "COMP12" 
    (   "EMPID" NUMBER, 
    "EMPLNAME" VARCHAR2(20), 
    "EMPFNAME" VARCHAR2(20), 
    "DEPTNO" NUMBER, 
    "MGRID" NUMBER, 
    PRIMARY KEY ("EMPID") ENABLE
    );

マイ コード (空行を 2 行追加するだけ)

           List<string> rt = new List<string>();
            foreach (string line in richtexBox1 .Lines)
            {
                if (line != "")
                {
                    rt.Add(line);
                    rt.Add("");
                }
            }
            richtexBox1 .Lines = rt.ToArray();
4

2 に答える 2

1

これでこれを試してみてください

 private void button1_Click(object sender, EventArgs e)
    {
        List<string> rt = new List<string>();
        foreach (string line in richTextBox1.Lines)
        {
            if (!string.IsNullOrEmpty(line.Trim()))
            {
                rt.Add(line);
            }
            if (line.Trim().EndsWith(";"))
            {
                rt.Add("\n");
            }
        }
        richTextBox1.Lines = rt.ToArray();
        richTextBox1.Refresh();
    }
于 2013-09-04T07:25:30.683 に答える
0

質問を解決していただきありがとうございます:

while (richTextBox1.Text.Contains("\n\n"))
    richTextBox1.Text = richTextBox1.Text.Replace("\n\n", "\n");
string[] linesafter = richTextBox1.Lines;
for (int i = 0; i < richTextBox1.Lines.Length; i++)
    if (richTextBox1.Lines[i].EndsWith(";"))
        linesafter[i] = linesafter[i] + "\n";
richTextBox1.Lines = linesafter;
于 2013-09-04T07:21:20.867 に答える