I only one datagrid, and one button.
the buttonwill process ' dtmyTable.newrow()' , However, the datagrid seems
didn't add the row byitself ??
Thanks 14 2853
Agnes,
Is your code something as?
dim dr as datarow = dtMyTable.NewRow()
dtMytable.rows.add(dr)
When not make it that way (you can do it in one sentence as well)?
I hope that helps?
:-)
Cor
" I only one datagrid, and one button. the buttonwill process ' dtmyTable.newrow()' , However, the datagrid
seems didn't add the row byitself ?? Thanks
Thanks Cor,
There is a property called dtMyTable.insertat (dr,position)
my grid got 5 rows, i need to insert the new row between 2nd and 3rd
I try dtMyTable.insertat(dr,2) . but it seems fail .. it still add to the
last row.
Can we do that "insert a row in specific row" ???
thanks again
"Cor Ligthert" <no**********@planet.nl> ¦b¶l¥ó
news:e6**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g... Agnes,
Is your code something as? dim dr as datarow = dtMyTable.NewRow() dtMytable.rows.add(dr)
When not make it that way (you can do it in one sentence as well)?
I hope that helps?
:-)
Cor " I only one datagrid, and one button. the buttonwill process ' dtmyTable.newrow()' , However, the datagrid seems didn't add the row byitself ?? Thanks
Hi Agnes,
I have seen this problem before and I did not get it to work.
Maybe somebody else know the problem.
Cor There is a property called dtMyTable.insertat (dr,position) my grid got 5 rows, i need to insert the new row between 2nd and 3rd I try dtMyTable.insertat(dr,2) . but it seems fail .. it still add to the last row. Can we do that "insert a row in specific row" ??? thanks again
Only reflected in the DataRowsCollection returned by Rows.
Dim nr As DataRow
Dim x As Int32
nr = DataSet11.Tables(0).NewRow
nr(0) = "Ox"
DataSet11.Tables(0).Rows.InsertAt(nr, 2)
For x = 0 To DataSet11.Tables(0).Rows.Count - 1
Debug.WriteLine(DataSet11.Tables(0).Rows(x).Item(0 ).ToString())
Next
//OUTPUT
Highfield Road
Abbey Close
Ox
Bower Way
Bower Way
Roadway To Hell
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:OW**************@TK2MSFTNGP11.phx.gbl... Thanks Cor, There is a property called dtMyTable.insertat (dr,position) my grid got 5 rows, i need to insert the new row between 2nd and 3rd I try dtMyTable.insertat(dr,2) . but it seems fail .. it still add to the last row. Can we do that "insert a row in specific row" ??? thanks again
"Cor Ligthert" <no**********@planet.nl> ¦b¶l¥ó news:e6**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g... Agnes,
Is your code something as? dim dr as datarow = dtMyTable.NewRow() dtMytable.rows.add(dr)
When not make it that way (you can do it in one sentence as well)?
I hope that helps?
:-)
Cor " I only one datagrid, and one button. the buttonwill process ' dtmyTable.newrow()' , However, the datagrid seems didn't add the row byitself ?? Thanks
I search from other newsgroup . some
said-------------------------------------------
The MSDN says that InsertAt could not be a solution to your problem. I think
this is an answer, that is: there is nothing wrong in the way you use the
InsertAt, but simply it cannot do what you expect it does. In other words,
it makes no much sense insisting in solving this matter using InsertAt, but
find alternatives like moving the rows in other DataTable object in the
order you like.
------------------------------------------------------------
"Cor Ligthert" <no**********@planet.nl> ¦b¶l¥ó
news:OI**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g... Hi Agnes,
I have seen this problem before and I did not get it to work.
Maybe somebody else know the problem.
Cor
There is a property called dtMyTable.insertat (dr,position) my grid got 5 rows, i need to insert the new row between 2nd and 3rd I try dtMyTable.insertat(dr,2) . but it seems fail .. it still add to
the last row. Can we do that "insert a row in specific row" ??? thanks again
Dim mdt As DataTable = Me.DataSet11.Tables(0).Copy
This will sort it
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... I search from other newsgroup . some said------------------------------------------- The MSDN says that InsertAt could not be a solution to your problem. I
think this is an answer, that is: there is nothing wrong in the way you use the InsertAt, but simply it cannot do what you expect it does. In other words, it makes no much sense insisting in solving this matter using InsertAt,
but find alternatives like moving the rows in other DataTable object in the order you like. ------------------------------------------------------------ "Cor Ligthert" <no**********@planet.nl> ¦b¶l¥ó news:OI**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g... Hi Agnes,
I have seen this problem before and I did not get it to work.
Maybe somebody else know the problem.
Cor
There is a property called dtMyTable.insertat (dr,position) my grid got 5 rows, i need to insert the new row between 2nd and 3rd I try dtMyTable.insertat(dr,2) . but it seems fail .. it still add to the last row. Can we do that "insert a row in specific row" ??? thanks again
Hi Terry
Because of your message I was thinking what was the kull again.
We had the same conclussion.
:-)
Cor
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable("bla")
dt.Columns.Add("Oxes")
Dim mystring() As String = {"Highfield Road", _
"Abbey(Close)", "Bower(Way)", "Bower(Way)", "Roadway To Hell"}
For i As Integer = 0 To mystring.Length - 1
Dim dr As DataRow = dt.NewRow
dr(0) = mystring(i)
dt.Rows.Add(dr)
Next
Dim dr2 As DataRow = dt.NewRow
dr2(0) = "Ox"
dt.Rows.InsertAt(dr2, 2)
Dim dtnew As DataTable = dt.Copy
dt = dtnew.Copy
DataGrid1.DataSource = dt
End Sub
Cor, your code work great.
However, my gird is master-detail relationship.
during my form load, My master and detail use the same dataset and with the
constraint key
I try dgDetail.datasource = dt
it seems reset my relationship ,all data are shown .......
"Cor Ligthert" <no**********@planet.nl> ¦b¶l¥ó
news:uh**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g... Hi Terry
Because of your message I was thinking what was the kull again.
We had the same conclussion.
:-)
Cor
Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim dt As New DataTable("bla") dt.Columns.Add("Oxes") Dim mystring() As String = {"Highfield Road", _ "Abbey(Close)", "Bower(Way)", "Bower(Way)", "Roadway To Hell"} For i As Integer = 0 To mystring.Length - 1 Dim dr As DataRow = dt.NewRow dr(0) = mystring(i) dt.Rows.Add(dr) Next Dim dr2 As DataRow = dt.NewRow dr2(0) = "Ox" dt.Rows.InsertAt(dr2, 2) Dim dtnew As DataTable = dt.Copy dt = dtnew.Copy DataGrid1.DataSource = dt End Sub
> Cor, your code work great. However, my gird is master-detail relationship. during my form load, My master and detail use the same dataset and with
the constraint key I try dgDetail.datasource = dt it seems reset my relationship ,all data are shown .......
daInv.fill(dsInvoice,"invoiceheader")
daInv.fill(dsInvoice,"invoicedetail")
dsInvoice.relations.add("fk_invno,"............... ..................etc)
Me.dgHeader.DataSource = dsInvoice
Me.dgHeader.DataMember = "invoiceheader"
Me.dgDetail.DataSource = dsInvoice
Me.dgDetail.DataMember = "Header.fK_invno"
So , as i choose the record in Header, the detail will switch too....... "Cor Ligthert" <no**********@planet.nl> ¦b¶l¥ó news:uh**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g... Hi Terry
Because of your message I was thinking what was the kull again.
We had the same conclussion.
:-)
Cor
Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim dt As New DataTable("bla") dt.Columns.Add("Oxes") Dim mystring() As String = {"Highfield Road", _ "Abbey(Close)", "Bower(Way)", "Bower(Way)", "Roadway To Hell"} For i As Integer = 0 To mystring.Length - 1 Dim dr As DataRow = dt.NewRow dr(0) = mystring(i) dt.Rows.Add(dr) Next Dim dr2 As DataRow = dt.NewRow dr2(0) = "Ox" dt.Rows.InsertAt(dr2, 2) Dim dtnew As DataTable = dt.Copy dt = dtnew.Copy DataGrid1.DataSource = dt End Sub
Actually, you can to an update on your adapter if you want or if you dont
have one, just to a Table.AcceptChanges and this will put the data in the
right order.
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:OL**************@TK2MSFTNGP09.phx.gbl... Cor, your code work great. However, my gird is master-detail relationship. during my form load, My master and detail use the same dataset and with the constraint key I try dgDetail.datasource = dt it seems reset my relationship ,all data are shown ....... daInv.fill(dsInvoice,"invoiceheader") daInv.fill(dsInvoice,"invoicedetail")
dsInvoice.relations.add("fk_invno,"............... ..................etc)
Me.dgHeader.DataSource = dsInvoice Me.dgHeader.DataMember = "invoiceheader"
Me.dgDetail.DataSource = dsInvoice Me.dgDetail.DataMember = "Header.fK_invno"
So , as i choose the record in Header, the detail will switch too.......
"Cor Ligthert" <no**********@planet.nl> ¦b¶l¥ó news:uh**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g... Hi Terry
Because of your message I was thinking what was the kull again.
We had the same conclussion.
:-)
Cor
Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim dt As New DataTable("bla") dt.Columns.Add("Oxes") Dim mystring() As String = {"Highfield Road", _ "Abbey(Close)", "Bower(Way)", "Bower(Way)", "Roadway To Hell"} For i As Integer = 0 To mystring.Length - 1 Dim dr As DataRow = dt.NewRow dr(0) = mystring(i) dt.Rows.Add(dr) Next Dim dr2 As DataRow = dt.NewRow dr2(0) = "Ox" dt.Rows.InsertAt(dr2, 2) Dim dtnew As DataTable = dt.Copy dt = dtnew.Copy DataGrid1.DataSource = dt End Sub
Hi Terry,
The first one could be done, the second one (acceptchanges) is written
somewhere I know, however that is the wrong solution. After that there are
no updates anymore processed.
Cor Actually, you can to an update on your adapter if you want or if you dont have one, just to a Table.AcceptChanges and this will put the data in the right order.
--
OHM ( Terry Burns ) . . . One-Handed-Man . . .
Hi Agnes,
Can you try it yourself what the same idea with the dataset.copy does?
dim dsnew as dataset = ds.copy
ds = dsnew.copy
Cor
Try your code, this time the detail grid won't show all the data.....
But as I run dt.insertat(dr,dgDetail.currentrowindex)
I test the currentrowindex which return correct row number. However, it
always insert the wrong row.
And this method only allow me to add one row.... [I put all the code in the
button's click event]
after press "once", it work but in wrong row, secondtime. no response.
"Cor Ligthert" <no**********@planet.nl> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g... Hi Agnes,
Can you try it yourself what the same idea with the dataset.copy does?
dim dsnew as dataset = ds.copy ds = dsnew.copy
Cor
Agnes,
Strange this works for me
Can you try it, do not forget to set that AllowSorting to false with this
method otherwise you get problems later.
I hope this helps?
Cor
\\\
Dim ds As New DataSet
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable("bla")
ds.Tables.Add(dt)
dt.Columns.Add("Oxes")
DataGrid1.AllowSorting = False
Dim mystring() As String = {"Highfield Road", _
"Abbey(Close)", "Bower(Way)", "Roadway To Hell"}
For i As Integer = 0 To mystring.Length - 1
Dim dr As DataRow = dt.NewRow
dr(0) = mystring(i)
dt.Rows.Add(dr)
Next
DataGrid1.DataSource = ds.Tables(0)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim dr2 As DataRow = ds.Tables(0).NewRow
dr2(0) = "Ox"
ds.Tables(0).Rows.InsertAt(dr2, DataGrid1.CurrentRowIndex)
Dim dsnew As DataSet = ds.Copy
ds = dsnew.Copy
DataGrid1.DataSource = ds.Tables(0)
End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ashish Shridharan |
last post by:
Hi All
I have been trying to add a control to the header cell of
a datagrid on my ASP.NET page. These controls are defined
in the HTML as ASP.NET web controls.
They are being added into the...
|
by: Bill C. |
last post by:
Hello,
I know this has been discussed a lot already because I've been searching
around for information the last few weeks.
I'm trying to implement a DataGridComboBoxColumn class. I've found...
|
by: BBFrost |
last post by:
Win2000
..Net 1.1 SP1
c# using Visual Studio
Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1
datagrid.
I've come to realize that a 'block' of rows highlighted within...
|
by: pei_world |
last post by:
I want to implement a key hit with enter to dropdown a combobox that is in
the datagrid. in this case I need to override its original behaviours. I
found some codes from the web. Does anyone know...
|
by: Rick |
last post by:
Hello all, I hope all is well with you.
I am having a seriously difficult time with this problem. Allow me to
set
up the problem.
I have a System.Web.UI.Page with the following controls...
| |
by: CVerma |
last post by:
Hi,
I have an embedded datagrid within a datalist. I am not able to
perfrom paging in the datagrid. Any ideas? Here is my code:
Here is my Simplegrid.cs file:
using System;
using...
|
by: CSL |
last post by:
I am using the DataGrid in a Windows Application, how can
I adjust the widths of each column individually.
|
by: Dave |
last post by:
Are there any add-on products or samples available that can do the following
in an vb.net datagrid
I want to compare 2 rows in a datagrid - one row from one database and
another row for another...
|
by: rn5a |
last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB
table. Users can modify the records using this DataGrid for which I am
using EditCommandColumn in the DataGrid. This is the...
|
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= |
last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor
information and the details loads the documents for that vendor in a
datagrid. Everything is working fine until I click...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |