断线事件
我正在做一个涉及数据输入的项目。
该表如下所示:dateTime
、enum
、text
、enum
、val1
, val2
, 文本
, enum
;
除 val1
和 val2
之外的所有值仅输入一次,并针对每个 val1 val2
对添加到表中。每行条目的 Val1
和 val2
都不同,它们都是条形码。
我希望使其尽可能高效,所以我想知道是否有一种方法可以在输入 Val1/2 时更新 DGV(其余的 val 当前作为变量存储在 对象[]
)。我正在使用标准条形码扫描仪,所以我虽然可以让它输入扫描仪在扫描条形码后输入的“换行符”上的值,所以我基本上是在寻找“scanner_LineBreak”事件或其他东西......
所以我'已经解决了这个问题...现在...我需要将所有数据写入 DGV 中的 text/excel/xml/whichevertheheck 文件...我知道结构不好...可能会重新开始。无论如何,我创建了一个空的 dataset 、空的 datatable 和一个空的 datarow (使用 object[]
填充填充表的行,该行填充集合),我现在尝试将所有数据输入到空 dataTable 中,以便我可以将其添加到数据集中,以便将数据写入 XML 。不用说它不起作用。我尝试使用 XmlSerializer 但将其导入 Access 和/或 IE 时出错。那么回到第 1 方...有没有办法从 DGV 填充 DS,或者有没有办法仅使用 DGV 数据编写任何文档。 注意:DGV = DataGridView
UPDATE
经过思考一段时间后,我意识到我可以为通过 Textchanged 事件输入的每个字符进行计数器增量,然后从那里执行我的操作想要...去想想...
int counter = 0;
private void textbox1_Textchanged(obj sender etc)
{
counter++;
if (counter % 10 == 0)
{
//shift focus to other textbox then do same to "save" values
}
}
I'm working on a project involving data entry.
The table looks like this : dateTime
, enum
, text
, enum
, val1
, val2
, text
, enum
;
All values apart from val1
and val2
are entered only once and are added to the table for each val1 val2
pair. Val1
and val2
are different for each row entry, they're both barcodes.
I'm looking to make it as efficient as possible so I'd like to know if there is a way to make the DGV update when Val1/2 have been entered ( the rest of the vals are currently stored as vars in an object[]
). I'm using a standard barcode scanner so I though I could make it enter the values on the "linebreak" the scanner enters after scanning the barcode so I'm basically looking for the "scanner_LineBreak" event or something...
So I've gotten beyond that problem... now.... I need to write the all the data to a text/excel/xml/whichevertheheck file from the DGV... bad structuring I know... might just start over. Any way, I've created an empty dataset , and empty datatable and an empty datarow (using the object[]
fill the row which fills the table which fills the set) and I'm now attempting to input all the data to the empty dataTable so I can add it to the dataset so I can write the data to XML . needless to say it's not working. I tried using the XmlSerializer but it errors when I import it to Access and/or IE . So going back to square 1... Is there a way to populate a DS from a DGV or is there a way to write whichever document using only DGV data.
note: DGV = DataGridView
UPDATE
After thinking about it for a while I realized that I could make a counter increment for every character entered with the Textchanged event and from there do what I'd wanted ... go figure...
int counter = 0;
private void textbox1_Textchanged(obj sender etc)
{
counter++;
if (counter % 10 == 0)
{
//shift focus to other textbox then do same to "save" values
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据我的经验,大多数条形码扫描仪都被视为键盘输入。数字后面跟着一个控制字符(通常是 CRLF 或制表符,但您需要检查扫描仪以了解它使用的字符)。然后,您可以使用 KeyDown 或 TextChanged 事件查看输入,如果它是控制字符,则执行更新逻辑。
In my experience, most bar code scanners are treated as keyboard input. The numbers will come in followed by a control character (usually CRLF or tab but you will need to check with your scanner to see what character it is using). You can then use the KeyDown or TextChanged events to look at the input and if it is the control character perform your updating logic.