Hi
I want to copy data from RadGridView1 to another RadGridView2. I want to copy selected row from datagridview 1 using checkbox to another datagridview2. and selected rows should be removed from datagridview1.
And if i selected from datagridview2 it should moved again to datagridview1.
For Each row As GridViewDataRowInfo In Me.RadGridView1 .Rows
if row.Cells(0).Value = true then''Checkbox column
dim i as int16= Me.RadGridView2.add
Me.RadGridView2.rows(i).cells(0).value= row.cells(0).vlaue.tostirng
End If
Next row
4 Answers, 1 is accepted
Hello Nandan,
If the RadGridView is in the DataBound scenario, you can use the bound collections to transfer the checked row. For your convenience, I have created a sample project which demonstrates what I have in mind. For the checkbox, I have used GridViewCheckBoxColumn. To catch the moment when the user checks a checkbox, I have subscribed to the ValueChanged event on both RadGridViews. In the event handlers, I am transferring the row to the other bound collection.
You can find the sample project attached to this reply.
As a side note, the attached project does not contain our DLLs. Before running the project you need to add a reference to all required assemblies from your C:\Program Files (x86)\Progress installation folder.
Regards,
Dinko | Tech Support Engineer
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi dinko
thanks for answer first raddatagridview 1 is databound and radgridview is not databound.
Regards
Nandan
Hi Nandan,
In this case, you can use the Rows collection of the second and add a row to it. For this purpose, you can use the AddNew() method of the Rows collection, which adds a row and return it. What's left is to transfer the cell's value.
private void RadGridView1_ValueChanged(object sender, EventArgs e)
{
if (this.radGridView1.ActiveEditor is RadCheckBoxEditor )
{
var rowForTransfer = this.radGridView1.SelectedRows.First();
var item = rowForTransfer.DataBoundItem as MyItem;
item.IsChecked = false;
leftItems.Remove(item);
var row = this.radGridView2.Rows.AddNew();
row.Cells[0].Value = item.IsChecked;
row.Cells[1].Value = item.Name;
}
}
private void RadGridView2_ValueChanged1(object sender, EventArgs e)
{
if (this.radGridView2.ActiveEditor is RadCheckBoxEditor && this.radGridView2.SelectedRows.Count > 0)
{
var rowForTransfer = this.radGridView2.SelectedRows.First();
MyItem myItem = new MyItem();
myItem.IsChecked = false;
myItem.Name = rowForTransfer.Cells[1].Value.ToString();
this.radGridView2.Rows.RemoveAt(rowForTransfer.Index);
leftItems.Add(myItem);
}
}
Regards,
Dinko | Tech Support Engineer
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hello Nandan,
As per your requirement in one of the posts above, I have converted my project to VB using our online Code Converter tool. You can find the project attached here.
Regards,
Dinko | Tech Support Engineer
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi dinko
thanks for your timely help. Kindly resolve my problem
Dim item = TryCast(rowForTransfer.DataBoundItem, dtdata)
Dim data As DataRowView = TryCast(RadGridView1.CurrentRow.DataBoundItem, DataRowView)
data.IsChecked = False
dt.Remove(item)
Dim row = Me.RadGridView2.Rows.AddNew()
row.Cells(0).Value = item.IsChecked
row.Cells(1).Value = item.Name
this code i want to replace with datatable
Private Function FetchAllDetails() As DataTable
Try
Dim parameters = New List(Of SqlParameter)()
With parameters
.Clear()
.Add(dbManager.CreateParameter("@ActionType", "FetchData", DbType.String))
End With
dtData = dbManager.GetDataTable("SP_ItemMaster_Select", CommandType.StoredProcedure, parameters.ToArray())
Catch ex As Exception
MessageBox.Show("Error:- " & ex.Message)
End Try
Return dtData
End Function
I am not aware about this coding
Private leftItems As BindingList(Of MyItem) = New BindingList(Of MyItem)()
Private rightItems As BindingList(Of MyItem) = New BindingList(Of MyItem)()
Regards
Nandan
Hello Nandan,
BindingList is a generic list type that has additional binding support. You can read more about it in the Binding to BindingList help article inside the RadGridView DataBinding section. If I have correctly understood your scenario, one of your RadGridViews is bound to a DataTable and the second is in unbound mode. I have modified my test project to demonstrate similar behavior with DataTable. You can find it attached to this reply.
Regards,
Dinko | Tech Support Engineer
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi Dinko
Its work correctly just what I needed. Thanks again for understanding my scenario. I am going through link about Binding to Bindinglist.
Regards,
Nandan Navale
Code not supported in my visual basic 2015
please send me the simple form design and code