我有一个RichTextBox
看起来像这样:
TEXT NEXT_TEXT 10.505 -174.994 0
TEXT NEXT_TEXT 100.005 174.994 90
TEXT NEXT_TEXT -10.000 -5.555 180
TEXT NEXT_TEXT -500.987 5.123 270
TEXT NEXT_TEXT 987.123 1.000 180
TEXT NEXT_TEXT 234.567 200.999 90
Run Code Online (Sandbox Code Playgroud)
我想替换"." 没有任何东西,把它放进ListBox
......
所以新文件看起来像这样:
TEXT NEXT_TEXT 10505 -174994 0
TEXT NEXT_TEXT 100005 174994 90
TEXT NEXT_TEXT -10000 -5555 180
TEXT NEXT_TEXT -500987 5123 270
TEXT NEXT_TEXT 987123 1000 180
TEXT NEXT_TEXT 234567 200999 90
Run Code Online (Sandbox Code Playgroud)
我想过将值乘以1000,但我不知道如何正确地对字符串进行匹配计算.
所以下一个想法就是这样做(但这不行):
// Splits the lines in …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创造一种与大多数人略有不同的手风琴.
我想做什么:
基本上寻找这样的东西:
正如您所看到的,这与大多数情况略有不同.我发现了一个类似于我想要的东西的现场演示,这可以在这里找到.
到目前为止我做了什么:
我一直在使用Cherry Framework并使用短代码来尝试使其工作,但是当我尝试从标题中扩展描述时遇到了问题.不确定是否有一种方法可以编辑手风琴短代码,以使描述符合全宽,但我认为这是理想的.
这是我到目前为止的代码:
[tabs direction="top" tab1="the first tab" tab2="the second tab" tab3="the third tab"]
[tab1]
[row]
[span4]
[accordion title="Title 1"] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras lorem lectus, porta et nulla ut, bibendum placerat sem. Aliquam a consequat ante, cursus posuere eros. Fusce ac turpis in turpis elementum malesuada vitae eu urna. Curabitur felis enim, luctus vitae pharetra eget, aliquam quis sem. …
Run Code Online (Sandbox Code Playgroud) 我有一个openFileButton
,当点击时,将打开一个如下所示的文件:
RefDeg Part# Xcntr Ycntr Rot PkgStyle
U6 IC-00279G 33.411 191.494 0 QFP32
U1 IC-00272G 38.011 200.644 90 BGA177
U5 IC-00273G 46.311 179.494 0 QFP40
R54 EXCLUDES 36.411 173.694 0 0402_2
R71 EXCLUDES 38.236 186.994 0 0402_2
R39 EXCLUDES 38.861 188.544 90 0402_2
C23 CAP-00130G 37.911 178.854 90 0402_3
C88 CAP-00010G 52.036 179.019 0 0603_4
C89 CAP-00010G 43.561 173.744 90 0603_3
X1 XTL-00013G 49.211 204.819 0 Crystal
X2 XTL-00012G 53.061 183.469 0 Crystal
D1 LED-00011G 58.611 181.394 0 …
Run Code Online (Sandbox Code Playgroud) 我将两个文件打开成两个单独的DGV.一旦打开并单击"格式"按钮,它将匹配两个单独的DGV中的所有行并将其复制到新的DGV中.
第一个 DGV看起来像这样(列标签):
Name P/N X Y Rotation PkgStyle
Run Code Online (Sandbox Code Playgroud)
而第二个 DGV看起来像这样:
PkgStyle P/D Feeder Vision Speed Machine Width Time
Run Code Online (Sandbox Code Playgroud)
这两个文件将匹配PkgStyle并将其余行连接在一起以获得第三个看起来像这样的DGV:
Name P/N X Y Rotation PkgStyle PkgStyle P/D Feeder Vision Speed Machine Width Time
Run Code Online (Sandbox Code Playgroud)
现在,正如您所料,可能存在不正确匹配的行,并且不会合并两个文件中的两组行.如果是这种情况,它将只输入第一个文件而不是第二个文件的信息.
所以一些示例数据可能如下所示:
Name P/N X Y Rotation PkgStyle PkgStyle P/D Feeder Vision Speed Machine Width Time
J11 1234 12 7 180 9876 9876 THETHING 1 1 1 UNI 12MM 1MS
R90 2222 19 9 0 1255 1255 ITEM 2 1 …
Run Code Online (Sandbox Code Playgroud) 我有这个代码:
List<string> lineList = new List<string>();
foreach (var line in theFinalList)
{
if (line.PartDescription != "")
lineList.Add(line.PartDescription + " " + line.PartNumber + "\n");
else
lineList.Add("N/A " + line.PartNumber + "\n");
//
//This is what I am trying to fix:
if (lineList.Contains("FID") || lineList.Contains("EXCLUDE"))
// REMOVE THE item in the lineList
}
Run Code Online (Sandbox Code Playgroud)
我试图theFinalList
在foreach循环中完成并将每行添加到一个名为的新列表中lineList
.添加后,我想删除该列表中包含文本"FID"或"EXCLUDE"的所有条目.
我无法删除条目,有人可以帮助我吗?
现在我有3个包含文本的RichTextBox.我从这些框中获取此文本并拆分每一行并将每个单独的行添加到其对应的ListBox.这是我的代码:
private void listFormatHelper()
{
// Splits the lines in the rich text boxes
var listOneLines = placementOneRichTextBox.Text.Split('\n');
var listTwoLines = placementTwoRichTextBox.Text.Split('\n');
var listUserLines = userDefinedRichTextBox.Text.Split('\n');
// Resest the text in the listboxes
placementOneListBox.ResetText();
placementTwoListBox.ResetText();
userDefinedListBox.ResetText();
// Set the selection mode to multiple and extended.
placementOneListBox.SelectionMode = SelectionMode.MultiExtended;
placementTwoListBox.SelectionMode = SelectionMode.MultiExtended;
userDefinedListBox.SelectionMode = SelectionMode.MultiExtended;
// Shutdown the painting of the ListBox as items are added.
placementOneListBox.BeginUpdate();
placementTwoListBox.BeginUpdate();
userDefinedListBox.BeginUpdate();
// Display the items in the listbox.
placementOneListBox.DataSource = listOneLines;
placementTwoListBox.DataSource = …
Run Code Online (Sandbox Code Playgroud) 我试图禁用输入到文本框中的所有击键,但以下内容除外:
0 1 2 3 4 5 6 7 8 9. (所以除了数字和'.'之外的所有键都应该被禁用)
现在我有以下代码,但它只检查是否输入了一个字母作为第一个值(更不用说它真的很邋)):
private void yDisplacementTextBox_TextChanged(object sender, EventArgs e)
{
if (yDisplacementTextBox.Text.ToUpper() == "A" || yDisplacementTextBox.Text.ToUpper() == "B" || yDisplacementTextBox.Text.ToUpper() == "C" ||
yDisplacementTextBox.Text.ToUpper() == "D" || yDisplacementTextBox.Text.ToUpper() == "E" || yDisplacementTextBox.Text.ToUpper() == "F" ||
yDisplacementTextBox.Text.ToUpper() == "G" || yDisplacementTextBox.Text.ToUpper() == "H" || yDisplacementTextBox.Text.ToUpper() == "I" ||
yDisplacementTextBox.Text.ToUpper() == "J" || yDisplacementTextBox.Text.ToUpper() == "K" || yDisplacementTextBox.Text.ToUpper() == "L" ||
yDisplacementTextBox.Text.ToUpper() == "M" || yDisplacementTextBox.Text.ToUpper() == "N" || yDisplacementTextBox.Text.ToUpper() == "O" …
Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的文件:
R.D. P.N. X Y Rot Pkg
L5 120910 64.770 98.425 180 SOP8
P4 120911 -69.850 98.425 180 SOIC12
L10 120911 -19.685 83.820 180 SOIC10
P4 120911 25.400 83.820 180 0603
L5 120910 62.484 98.425 180 SOP8
L5 120910 99.100 150.105 180 SOP8
.. ...... ...... ...... .. .......
Run Code Online (Sandbox Code Playgroud)
我想string.Split()
用来拆分每个字符串,然后检查每一行"string [0]"的第一个值.如果有相同字符串[0]的重复项,我想在字符串[0]的末尾添加一个递增的" - #".所以它会像string[0] + "-i"
.....
我的意思是,对于L5
的在上面的txt文件,他们将被更改为L5-1
,L5-2
,L5-3
.同样适用于P4
's(即P4-1
,, P4-2
)....
所以新的.txt看起来像这样:
R.D. P.N. X Y Rot …
Run Code Online (Sandbox Code Playgroud) 我有一个RTB加载了一个如下所示的文件:
J6 INT-00113G 227.905 174.994 180 SOIC8
J3 INT-00113G 227.905 203.244 180 SOIC8
U13 EXCLUDES 242.210 181.294 180 QFP128
U3 IC-00276G 236.135 198.644 90 BGA48
U12 IC-00270G 250.610 201.594 0 SOP8
J1 INT-00112G 269.665 179.894 180 SOIC16
J2 INT-00112G 269.665 198.144 180 SOIC16
Run Code Online (Sandbox Code Playgroud)
我想使用string.Split()方法删除最后一列.
到目前为止,我有:
// Splits the lines in the rich text boxes
string[] lines = richTextBox2.Text.Split('\n');
foreach (var newLine in lines)
{
newLine.Split(' ');
line = line[0] + line[1] + line[2] + line[3] + line[4]; #This is the …
Run Code Online (Sandbox Code Playgroud) 可能重复:
如何正确舍入和格式化小数?
我有这个:
double xValue = 0.0;
double yValue = 0.0;
foreach (var line in someList)
{
xValue = Math.Round(Convert.ToDouble(xDisplacement - xOrigin), 2);
yValue= Math.Round(Convert.ToDouble(yDisplacement + yOrigin), 2);
sw.WriteLine("( {0}, {1} )", xValue, yValue);
}
Run Code Online (Sandbox Code Playgroud)
当它进行数学运算时,假设舍入到2位小数.
..当数字类似于6.397时,它会将其四舍五入为6.4而不包括尾随的"0".
如何在数字末尾添加"0"?
如果我将此添加到BEFORE(除非有更好的方法可以做到这一点?)上面的foreach循环 ...:
string properX = xValue.ToString().Replace(".", "");
string properY = yValue.ToString().Replace(".", "");
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
我有一个我正在阅读的文件,分成不同的列表并将它们输出到RichTextBox然后被读入3个不同的列表框.我目前正在做所有这些,但是我遇到了一些我不知道如何修复/解决的问题.
我的代码在下面,我似乎无法理解为什么当它到达代码的Match twoRegex = Regex.Match(...)部分时它无法正常工作.
码:
private void SortDataLines()
{
try
{
// Reads the lines in the file to format.
var fileReader = File.OpenText(openGCFile.FileName);
// Creates a list for the lines to be stored in.
var placementUserDefinedList = new List<string>();
// Reads the first line and does nothing with it.
fileReader.ReadLine();
// Adds each line in the file to the list.
while (true)
{
var line = fileReader.ReadLine();
if (line == null)
break;
placementUserDefinedList.Add(line);
}
// Creates …
Run Code Online (Sandbox Code Playgroud) 我有一个列表,我想以多种方式排序.
我的清单是用这个:
theMainList.Add(new LoadLine(theChipList[count].Name, theChipList[count].PartNumber,
theChipList[count].XPlacement, theChipList[count].YPlacement,
theChipList[count].Rotation, theChipList[count].PkgStyle,
theChipList[count].PackageType, theChipList[count].PartDescription,
theChipList[count].Feeder, theChipList[count].Vision,
theChipList[count].Speed, theChipList[count].Machine,
theChipList[count].TapeWidth, theChipList[count].PlacingTime));
Run Code Online (Sandbox Code Playgroud)
我开始使用每一行foreach(var line in theMainList)
.
现在,对于每一个line
我需要比较某些位置并相应地对它们进行排序.
所以,第一我想比较是每个line.Speed
和数字组织名单(所以如果速度是1,2,3,4,5等在列表中的第一行是具有行line.Speed
等于1,然后2,等)
SECOND我想按现在的顺序排序更新的列表line.Speed
.我想line.PackageStyle
按顺序排序:
"FIDUCIAL", "FID", "FID0", "FID1", "FID2", "FID3", "FID4", "FID5",
"FID6", "FID7", "FID8", "FID9", "RES", "0402", "0201", "0603",
"0805","1206", "1306", "1608", "3216", "2551", "1913", "1313",
"2513","5125", "2525", "5619", "3813", "1508", "6431", "2512",
"1505","2208", "1005", "1010", "2010", "0505", "0705", "1020",
"1812","2225", "5764", "4532", …
Run Code Online (Sandbox Code Playgroud) 我正在使用此代码向字典添加信息:
foreach (string word in lineList)
{
if (dictionary.ContainsKey(word))
dictionary[word]++;
else
dictionary[word] = 1;
}
// I believe this is what needs to change..?
var ordered = from k in dictionary.Keys select k;
Run Code Online (Sandbox Code Playgroud)
当我用StreamWriter
它打印出来的时候,按照它添加到的顺序将它打印出来dictionary
.
我想要做的是按顺序打印出来,首先比较PartDescription
然后将PartNumber
数字打印出来.
文件看起来像这样:
PartDescription PartNumber Name X Y Rotation
1608RTANT 147430 J1 20.555 -12.121 180
TANTD 148966 J2 20.555 -12.121 270
SOMETHING 148966 R111 20.555 -12.121 360
SOMETHING 148966 C121 20.555 -12.121 180
SOMETHING 148966 R50 205.555 -12.121 180 …
Run Code Online (Sandbox Code Playgroud) c# ×11
list ×4
datagridview ×2
duplicates ×2
sorting ×2
split ×2
text-files ×2
.net ×1
add ×1
concat ×1
contains ×1
css ×1
decimal ×1
dictionary ×1
file ×1
foreach ×1
html ×1
input ×1
javascript ×1
jquery ×1
keyboard ×1
listbox ×1
math ×1
move ×1
regex ×1
replace ×1
richtextbox ×1
rounding ×1
save ×1
string ×1
textbox ×1
winforms ×1
wordpress ×1