473,811 Members | 2,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

An array and a datagrid

Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar
Nov 21 '05 #1
9 2467
Hi,

Here is an example that uses an arraylist.
http://www.onteorasoftware.com/Downl...todatagrid.zip

Ken
------------------
"rodchar" <ro*****@discus sions.microsoft .com> wrote in message
news:13******** *************** ***********@mic rosoft.com...
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar
Nov 21 '05 #2
Ken,

Is there a way to get a comma-delimited field into an array list. I know I
can do it with split function but that only works with arrays.

rodchar

"Ken Tucker [MVP]" wrote:
Hi,

Here is an example that uses an arraylist.
http://www.onteorasoftware.com/Downl...todatagrid.zip

Ken
------------------
"rodchar" <ro*****@discus sions.microsoft .com> wrote in message
news:13******** *************** ***********@mic rosoft.com...
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar

Nov 21 '05 #3
Rodchar,

A comma delimited field is just a string so that is easy to put in a
arraylist.
When you want first an object from it, that should go as well and than using
the split as you said and than into the arraylist would not be a problem as
well..

However than to use it in a datagrid will be iimpossible I think or with a
lot of work.

While when it is a file, this goes almost in one time.

\\\
Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & _
path & ";Extended Properties=""Te xt;HDR=No;FMT=D elimited\"""
Dim conn As New OleDb.OleDbConn ection(ConStr)
Dim da As New OleDb.OleDbData Adapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show (ex.ToString)
End Try
DataGrid1.DataS ource = ds.Tables(0)
End Sub
///
I hope this helps a little bit?
Cor

"rodchar" <ro*****@discus sions.microsoft .com>
Ken,

Is there a way to get a comma-delimited field into an array list. I know I
can do it with split function but that only works with arrays.

rodchar

"Ken Tucker [MVP]" wrote:
Hi,

Here is an example that uses an arraylist.
http://www.onteorasoftware.com/Downl...todatagrid.zip

Ken
------------------
"rodchar" <ro*****@discus sions.microsoft .com> wrote in message
news:13******** *************** ***********@mic rosoft.com...
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar

Nov 21 '05 #4
Hi,

You can only bind to a one dimensional array

Ken
--------------------
"rodchar" <ro*****@discus sions.microsoft .com> wrote in message
news:D0******** *************** ***********@mic rosoft.com...
Ken,

Is there a way to get a comma-delimited field into an array list. I know I
can do it with split function but that only works with arrays.

rodchar

"Ken Tucker [MVP]" wrote:
Hi,

Here is an example that uses an arraylist.
http://www.onteorasoftware.com/Downl...todatagrid.zip

Ken
------------------
"rodchar" <ro*****@discus sions.microsoft .com> wrote in message
news:13******** *************** ***********@mic rosoft.com...
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar

Nov 21 '05 #5
thank you. this helps.

"rodchar" wrote:
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar

Nov 21 '05 #6
Cor,

how exactly do I get the csv field into an arraylist?
I've tried
arrlist=ctype(a rr,arrlist) dosen't work
"Cor Ligthert" wrote:
Rodchar,

A comma delimited field is just a string so that is easy to put in a
arraylist.
When you want first an object from it, that should go as well and than using
the split as you said and than into the arraylist would not be a problem as
well..

However than to use it in a datagrid will be iimpossible I think or with a
lot of work.

While when it is a file, this goes almost in one time.

\\\
Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & _
path & ";Extended Properties=""Te xt;HDR=No;FMT=D elimited\"""
Dim conn As New OleDb.OleDbConn ection(ConStr)
Dim da As New OleDb.OleDbData Adapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show (ex.ToString)
End Try
DataGrid1.DataS ource = ds.Tables(0)
End Sub
///
I hope this helps a little bit?
Cor

"rodchar" <ro*****@discus sions.microsoft .com>
Ken,

Is there a way to get a comma-delimited field into an array list. I know I
can do it with split function but that only works with arrays.

rodchar

"Ken Tucker [MVP]" wrote:
Hi,

Here is an example that uses an arraylist.
http://www.onteorasoftware.com/Downl...todatagrid.zip

Ken
------------------
"rodchar" <ro*****@discus sions.microsoft .com> wrote in message
news:13******** *************** ***********@mic rosoft.com...
Hey all,

what's the best way to get the contents of an array into a datagrid, edit
the values, and then save edited values back into array format?

thanks,
rodchar


Nov 21 '05 #7
rodchar,

You can add everything to an arraylist with
myarraylist.add (whatever)

I hope this helps?

Cor

"rodchar" <ro*****@discus sions.microsoft .com>
Cor,

how exactly do I get the csv field into an arraylist?
I've tried
arrlist=ctype(a rr,arrlist) dosen't work
"Cor Ligthert" wrote:
Rodchar,

A comma delimited field is just a string so that is easy to put in a
arraylist.
When you want first an object from it, that should go as well and than
using
the split as you said and than into the arraylist would not be a problem
as
well..

However than to use it in a datagrid will be iimpossible I think or with
a
lot of work.

While when it is a file, this goes almost in one time.

\\\
Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & _
path & ";Extended
Properties=""Te xt;HDR=No;FMT=D elimited\"""
Dim conn As New OleDb.OleDbConn ection(ConStr)
Dim da As New OleDb.OleDbData Adapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show (ex.ToString)
End Try
DataGrid1.DataS ource = ds.Tables(0)
End Sub
///
I hope this helps a little bit?
Cor

"rodchar" <ro*****@discus sions.microsoft .com>
> Ken,
>
> Is there a way to get a comma-delimited field into an array list. I
> know I
> can do it with split function but that only works with arrays.
>
> rodchar
>
> "Ken Tucker [MVP]" wrote:
>
>> Hi,
>>
>> Here is an example that uses an arraylist.
>> http://www.onteorasoftware.com/Downl...todatagrid.zip
>>
>> Ken
>> ------------------
>> "rodchar" <ro*****@discus sions.microsoft .com> wrote in message
>> news:13******** *************** ***********@mic rosoft.com...
>> Hey all,
>>
>> what's the best way to get the contents of an array into a datagrid,
>> edit
>> the values, and then save edited values back into array format?
>>
>> thanks,
>> rodchar
>>
>>
>>


Nov 21 '05 #8
Set the DataGrid's datasource property to the array/arraylist object.

Assign the DataGrid.Item(i ndex) to the array/arraylist object.

Check out my article, "DataSet, DataGrid and the Treeview controls" at
developersdex.c om.

with regards,
J.V.Ravichandra n
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandra n+J.V.&cob=aspn etpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID= P3966388&BN=999 &PN=2
- Or, just search on "J.V.Ravichandr an"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #9
when I bind my array to the datagrid, all I get is the length column, how do
I get the actual values to show up?
"Ravichandr an J.V." wrote:
Set the DataGrid's datasource property to the array/arraylist object.

Assign the DataGrid.Item(i ndex) to the array/arraylist object.

Check out my article, "DataSet, DataGrid and the Treeview controls" at
developersdex.c om.

with regards,
J.V.Ravichandra n
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandra n+J.V.&cob=aspn etpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID= P3966388&BN=999 &PN=2
- Or, just search on "J.V.Ravichandr an"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2769
by: Eugene | last post by:
Hello all, I've been trying to figure this out for a few days now, and still have no clue what's going on... I have a few related tables in MS Access (Clients, Cars, Sales), and a datagrid, binded to dataview. Here's a catch - whenever I select a client, and then find a car which belongs to this client, and click on empty space in datagrid (that is in gray area below rows) - I get "Index was outside the bounds of the array" error......
2
864
by: Jason Coyne Gaijin42 | last post by:
I have seen several people looking for a way to access the Columns collection when using the AutoGenerate = true option. Some people have gotten so far as to find the private autoGenColumnsArray that has the information, but we as developers have no way to access this information. I have come up with a solution for the problem, (as I am sure many others have) using reflection. Here is some sample code that will print out the auto...
4
4846
by: mirek | last post by:
Hello, is there a way how to create data view (via datagrid) of a 2dim. array? I've data which I've got via SOAP call - it is a customer list, I want to simply display it in an datagrid. Can someone point me to an example how to do it? thanx Mirek
3
2328
by: AFN | last post by:
I need to manually create the data to be shown in a datagrid (or some data table object). Should I create an array and bind the array to the datagrid OR should I create a temporary dataset and bind that to the datagrid? I have never done either (usually I get a recordset from a stored procedure and bind results directly). I also don't know which is faster. Whichever you suggest, can you give a couple lines of sample code? Thank...
4
2117
by: Manny Chohan | last post by:
hi guys, my code is returning an array and i need to create datagrid so that i can have sorting and implement prev....next function on it to navigate. is there any way this can be done in codebehind file. I am using c#. Thanks Manny
7
2565
by: Jed | last post by:
I have a web service method that returns an array of custom objects marked serializeable with fully described public properties. When I bind the results to a DataGrid I can access the properties in the ItemDataBound event of the codebehind but I can't access them declaratively in the HTML code? Here is the code to call the method. net.mysite.www.WSInterface proxy; proxy = new net.mysite.www.WSInterface();
1
2827
by: epigram | last post by:
Well, conceptually this is what I want to do. I was hoping to use an ArrayList to build a (dynamic) array of string arrays, and then bind the ArrayList object to a DataGrid. I can do that, but it doesn't give me the results that I wanted. Is there a way to successfully do this? I even tried to bind a multidimensional array (string ) to a DataGrid, but an exception is thrown with the message "Array was not a one-dimensional array". I'm...
10
2757
by: mark | last post by:
I have a simple windows application that has a function to read a csv file and enter the values into an array A as double(,). Also, an instance of form 2 (which has a DataGrid) is created and the values of A are used to populate the grid via a DataView. The instance of form2 is called Matrix_A . The basic layout is as follows: #Region "Globals Dim A As Double(,) Dim Matrix_A As form2 #End Region
4
1182
by: mark | last post by:
(windows app not web) I have a procedure to populate a given datagrid (Datagrid1) with a dataset from an indexed data connection. It works: Globals: Dim FileName1 As String Dim DS As System.Data.DataSet Dim OleDbConnection1(20) As System.Data.OleDb.OleDbConnection Dim OleDbDataAdapter1(20) As System.Data.OleDb.OleDbDataAdapter Dim CurrentIndex As Integer = 0
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10652
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10395
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10408
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10137
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9211
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3026
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.