Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-27-2005, 09:33 AM
|
#1
|
Member
Registered: May 2005
Posts: 275
Rep:
|
Appending data to a datagrid
I am currently working on an application where I will need to progressively build a data grid. I have a text file that looks like this:
1006, 32.56, .1348, .0466
1007, 33.12, .1234, .9876
I am going to need to read each line one at a time. One the first time around 1006 needs to go into "its text box" and so on. From there I need to query based on line 1's data and print to datagrid. Then I need to read line two and clear 1006 from the text box and put in 1007 and so on and then query for this set of data and append it to the data grid at the end of the data from the first line.
Can anybody help me as to how this would be done?
|
|
|
07-28-2005, 07:37 AM
|
#2
|
Member
Registered: May 2005
Posts: 275
Original Poster
Rep:
|
appending data to a data grid VB.net
I am working on an application in which I am going to need to append data to a data grid. Basically, I am going to have a loop that will read a text box, query for info in text box, print to data grid, change info in text box, query and print again and so on. I will need the first set of data displayed, then the next set appended to the previous set at the end, etc, etc. Can anyone help me with how to do this?
|
|
|
07-28-2005, 08:11 AM
|
#3
|
LQ Newbie
Registered: Jul 2005
Distribution: SuSE 9.3 Pro and FC3
Posts: 17
Rep:
|
Don't know that this has anything to do with linux dev but....
If you are using a dataset...
Create a dataview on the dataset.
Bind the dataview ( not the dataset ) to the grid.
Then when you want to add data to the grid...
Grab the dataview back from the grid's datasource.
Add the data to the dataview.
Re-bind the dataview to the grid.
If you are using a custom object ( i.e. collection )...
Bind the collection to the grid
Then when you want to add data to the grid....
Grab the collection back from the grid's datasource
Add the new item to the collection.
Re-bind the colleciton to the grid.
|
|
|
07-28-2005, 08:15 AM
|
#4
|
Member
Registered: May 2005
Posts: 275
Original Poster
Rep:
|
would you be able to give me some coding examples of how to do this. I have never dealt with a data view before nor heard of it. Some source code would be a great help.
|
|
|
07-28-2005, 08:16 AM
|
#5
|
Member
Registered: May 2005
Posts: 275
Original Poster
Rep:
|
I am coding in vb.net not a linux language
|
|
|
07-28-2005, 08:52 AM
|
#6
|
LQ Newbie
Registered: Jul 2005
Distribution: SuSE 9.3 Pro and FC3
Posts: 17
Rep:
|
There are tons of examples on datagrids, datasets, and dataviews in MSDN and on the web.
Doing a google search for any/all of those things will bring you more hits than you can read.
|
|
|
07-28-2005, 08:57 AM
|
#7
|
Member
Registered: May 2005
Posts: 275
Original Poster
Rep:
|
I tried something like this and got an Ora - 01722: Invalid Name the second time through the loop on the bolded line.
Code:
Private Sub butReadFromtextfile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butReadFromtextfile.Click
Try
Dim mLine As String
Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader
oRead = oFile.OpenText("C:\Documents and Settings\alogue\Desktop\Coil PDI\PDI.txt")
While oRead.Peek <> -1
mLine = oRead.ReadLine()
'Get and split line details
Dim mControlInfo(4) As String 'Sets up the 3 elements on the current line
mControlInfo = mLine.Split(",") 'Tab between the quotes - i used commas, much easier
txtgradecode.AppendText(mControlInfo(0))
txtwidth.AppendText(mControlInfo(1))
txthbgauge.AppendText(mControlInfo(2))
txttargetgauge.AppendText(mControlInfo(3))
Dim coilpdi As String
Dim CoilPDIRowCount As Integer
Dim PDIDataset As New DataSet
Dim myConnection As New OracleConnection("Data Source=DUF_TCM; User ID=PCC;Password=DUFERCO")
myConnection.Open()
'Queries for the rolls that match the specified pdi
coilpdi = "Select * from tcm_planned_coil where process_status = 'PLN' and grade_code ='" + txtgradecode.Text + "' and width = '" + txtwidth.Text + "' and hot_band_gauge='" + txthbgauge.Text + "' and target_gauge='" + txttargetgauge.Text + "' order by schedule_number, sequence_number"
Dim PDICommand As New OracleCommand(coilpdi, myConnection)
Dim PDIAdapter As New OracleDataAdapter(PDICommand)
'clears the dataset
PDIDataset.Clear()
'using the command object, open a data adapter
PDIAdapter.SelectCommand = PDICommand
'Fills the data adapter with the dataset
PDIAdapter.Fill(PDIDataset, "Table2")
With Me.dgQueryResults
.DataSource = PDIDataset 'display the data in the datagrid
.NavigateTo(0, -1) 'expand the datagrid one level
.NavigateTo(0, "Table2") 'expand the datagrid down to the child level to show query results
.ParentRowsVisible = False
.AllowSorting = True
.AllowNavigation = True
.AllowDrop = False
.ColumnHeadersVisible = True
.PreferredColumnWidth = 300 'Set in pixels
.TabStop = False
.Enabled = True
.Visible = True
.ReadOnly = True
.AlternatingBackColor = System.Drawing.Color.Bisque
End With
CoilPDIRowCount = PDIDataset.Tables("Table2").Rows.Count
End While
oRead.Close()
AddCellFormattingColumnStyles(Me.dgQueryResults, New FormatCellEventHandler(AddressOf FormatGridCells)) ' This is a private Sub within this class.
myConnection.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information)
Finally
End Try
End Sub
Does this look like it will append data or just write over the first set? I have google appending data to a datagrid and data views alot and havent found any useful ino yet.
|
|
|
All times are GMT -5. The time now is 08:00 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|