如何将qr代码拆分为列 [英] How can I split qr codes to column
本文介绍了如何将qr代码拆分为列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi Team,
我需要帮助将qr代码拆分为列。我创建了一个表格,当我扫描
qrcode时,文本框会给出字符并转移到表格中。该表有5列,我需要根据(:)分割字符。
我的问题是qr代码正在扫描,文本框正在给出结果,但是当
通过文字改变事件转移到桌面,但它没有分割字符。
请帮我解决。以下是截图链接
Hi Team,
I need a help on spliting qr code to columns. I created a table, and when I scanned
the qrcode the textbox will give characters and will transfer to the table. The table has 5 columns and I need to split the characters based on (":").
My problem is the qr code is scanning and the textbox is giving result, but when
transferring to the table via text changed event, but its not spliting the characters.
Please help me to solve it.Below is the screenshot link
<a href="https://ibb.co/hDMuoc"><img src="https://preview.ibb.co/hqC0Tc/1111.jpg" alt="1111" border="0"></a>
[^][^]
What I have tried:
private void result_TextChanged(object sender, EventArgs e)
{
DataTable Table = new DataTable();
DataRow RowValues = database1DataSet.Table.NewRow();
var stringToSplit = result.Text;
var elements = result.Text.Split(':');
{
RowValues[1] = stringToSplit;
}
database1DataSet.Table.Rows.Add(RowValues);
this.tableAdapterManager.UpdateAll(this.database1DataSet);
this.tableTableAdapter.Fill(this.database1DataSet.Table);
this.tableBindingSource.MoveLast();
}
推荐答案
你将文本拆分为可变的元素
,然后将stringToSplit
添加到新行中,但这是原始的未分裂的文字。您应该在split元素上使用foreach
循环,并将每个元素添加到一个新行。
You are splitting the text into the varaiableelements
, but then you addstringToSplit
into the new row, but that is the original unsplit text. You should use aforeach
loop on the split elements and add each one to a new row.
我将更改您的代码方式:
I'd change your code this way:
DataTable dt = (DataTable) YourDataGridView.DataSource;
string qr = "rr:rr:rr:rr:rr";
DataRow dr = dt.NewRow();
foreach(int i in Enumerable.Range(1,5))
{
dr.SetField(i, qr.Split(new string[]{":"}, StringSplitOptions.RemoveEmptyEntries)[i-1]);
}
dt.Rows.Add(dr);
YourDataGridView.DataSource = dt;
这篇关于如何将qr代码拆分为列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文