473,466 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Datagrid view from single textbox

1 New Member
Hi
I have a note sorter machine that is connected to serial port. I am able to get the data from it in a textbox that is as folllows:
-----------------------------JL206F ID:VDE40050

2015/05/29 11:02:19

JBatch_No.:067

JOperator ID:15

--------------------------------

Mixed Counting

W--------------------------------Deposit Amount: 0.00

--------------------------------

denom count value

UVK(|????DW50D 1 50.00

JUVK(|????DW20D 1 20.00

JUVK(|????DW10ND 1 10.00

J--------------------------------

Total: 3 80.00

--------------------------------

Coin: 0.00

--------------------------------

Balance: 0.00


Now I want them to arrange in datagrid. How can I do that.

My code is as follows:
Expand|Select|Wrap|Line Numbers
  1. namespace SerialPortListener
  2. {
  3.     public partial class MainForm : Form
  4.     {
  5.         SerialPortManager _spManager;
  6.         public MainForm()
  7.         {
  8.             InitializeComponent();
  9.  
  10.             UserInitialization();
  11.         }
  12.  
  13.  
  14.         private void UserInitialization()
  15.         {
  16.             _spManager = new SerialPortManager();
  17.             SerialSettings mySerialSettings = _spManager.CurrentSerialSettings;
  18.             serialSettingsBindingSource.DataSource = mySerialSettings;
  19.             portNameComboBox.DataSource = mySerialSettings.PortNameCollection;
  20.             baudRateComboBox.DataSource = mySerialSettings.BaudRateCollection;
  21.             dataBitsComboBox.DataSource = mySerialSettings.DataBitsCollection;
  22.             parityComboBox.DataSource = Enum.GetValues(typeof(System.IO.Ports.Parity));
  23.             stopBitsComboBox.DataSource = Enum.GetValues(typeof(System.IO.Ports.StopBits));
  24.  
  25.             _spManager.NewSerialDataRecieved += new EventHandler<SerialDataEventArgs>(_spManager_NewSerialDataRecieved);
  26.             this.FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
  27.         }
  28.  
  29.  
  30.         private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
  31.         {
  32.             _spManager.Dispose();   
  33.         }
  34.  
  35.         void _spManager_NewSerialDataRecieved(object sender, SerialDataEventArgs e)
  36.         {
  37.             if (this.InvokeRequired)
  38.             {
  39.                 // Using this.Invoke causes deadlock when closing serial port, and BeginInvoke is good practice anyway.
  40.                 this.BeginInvoke(new EventHandler<SerialDataEventArgs>(_spManager_NewSerialDataRecieved), new object[] { sender, e });
  41.                 return;
  42.             }
  43.  
  44.             int maxTextLength = 1000; // maximum text length in text box
  45.             if (tbData.TextLength > maxTextLength)
  46.                 tbData.Text = tbData.Text.Remove(0, tbData.TextLength - maxTextLength);
  47.  
  48.  
  49.  
  50.             string str = Encoding.ASCII.GetString(e.Data);
  51.  
  52.             tbData.AppendText(str);
  53.             tbData.ScrollToCaret();
  54.  
  55.  
  56.  
  57.  
  58.         }
  59.  
  60.         // Handles the "Start Listening"-buttom click event
  61.         private void btnStart_Click(object sender, EventArgs e)
  62.         {
  63.             _spManager.StartListening();
  64.         }
  65.  
  66.         // Handles the "Stop Listening"-buttom click event
  67.         private void btnStop_Click(object sender, EventArgs e)
  68.         {
  69.             _spManager.StopListening();
  70.         }
  71.  
Jun 2 '15 #1
0 1282

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: ComputerStop | last post by:
I am attempting to print a datagridview. I have not found any method that works successfully. Has any one been successful with this?
2
by: Bob | last post by:
I looked at the sample in the msdn january 2005 - Introducing a new datagrid, but the project downloaded failed to open. Any one can point me to a bit of code on how to go and select an image...
0
by: shukyh | last post by:
Hi all I would like to generate an HTML page from datagridview in win application (not webform). In th datagrid view I have DataGridViewCheckBoxColumn columns. How Can i do this? Thanks, Shuky
0
by: Tony A. | last post by:
I'm using VB 2005 with MS Access for as the database. I have a table (tblItem) that has two columns, ItemNum (key field) and ItemDescription. I also have a second table (tblOrdersDetail), this...
1
by: radhikabista | last post by:
hey friends , i m not being able to save the updates in datagrid view when i press buttonsave_ gridview i have a class customer with two methods one to get the dataset and other to update database:...
1
mafaisal
by: mafaisal | last post by:
Hello Experts I am Using vb.net 2005 Hw To Put DateTime Picker in Datagrid view I have to sea Datetime Picker in Specified Cilomn of Datagrid I try This But The Location Hw To Change to the...
9
by: Gwyn Jones | last post by:
I've seen many answers on how a multi select listbox can be concatenated into a textbox. But what I'm after is to be able to select a single element of 4 different list boxes to concatenate into a...
0
by: Syed Hadi | last post by:
i want a single cell click function... but when i am pressing anywhere in the datgridview this cell is working ... how to use single cell..in dgv private void dataGridView1_CellClick(object...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.