Private Sub RadDock1_ActiveWindowChanging(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.Docking.DockWindowCancelEventArgs) Handles RadDock1.ActiveWindowChanging |
' Salvo il Layout del tab che sto chiudendo |
For Each c As Control In RadDock1.ActiveWindow.Controls |
Select Case c.GetType.ToString |
Case "Commesse" |
Dim mycontrol As AnagraficaCommesse = TryCast(c, AnagraficaCommesse) |
mycontrol.SaveGridLayout() |
Case "Articoli" |
Dim mycontrol As Commesse_Articoli = TryCast(c, Commesse_Articoli) |
mycontrol.SaveGridLayout() |
If mycontrol.RadGridView1.IsInEditMode() Then |
If MsgBox("Un record non è stato salvato! Si desidera salvarlo ora?", MsgBoxStyle.YesNo, "Salvare i dati?") = MsgBoxResult.Yes Then |
Try |
mycontrol.RadGridView1.EndEdit() |
mycontrol.UpdateDataSource() |
Catch ex As Exception |
MsgBox("Si è verificato un problema durante il salvataggio dei dati. Controllare che i dati inseriti siano corretti", MsgBoxStyle.Critical, "Errore") |
e.Cancel = True |
End Try |
Else |
mycontrol.RadGridView1.EndEdit() |
End If |
End If |
End Select |
Next |
End Sub |
Hi, i'm having trouble trying to export the grid. Whenever i export the data i only get the visible part of it. I cannot find to much info about how i have to do it. Could someone please help me?
Regards.
radButtonItem.Shortcuts.Add(new RadShortcut(0,Keys.F5)); |
Public Class TestMenuItem |
Inherits RadMenuItem |
Public Sub New() |
Me.New("", Nothing) |
End Sub |
Public Sub New(ByVal text As String) |
Me.New(text, Nothing) |
End Sub |
Public Sub New(ByVal text As String, ByVal tag As Object) |
MyBase.New(text, tag) |
End Sub |
End Class |
Public Class Form1 |
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load |
Dim mi1 As New RadMenuItem("test1") |
Dim mi2 As New testMenuItem("test2") |
Me.RadMenuItem1.Items.Add(mi1) |
Me.RadMenuItem1.Items.Add(mi2) |
End Sub |
End Class |
for (int i = 0; i < dtTabs.Rows.Count; i++) |
{ |
Page cp = new Page(dtTabs.Rows[i].ItemArray[1].ToString(), sCon, at, isPrimary,this); |
cp.Dock = DockStyle.Fill; |
RadPanel rp = new RadPanel(); |
rp.Controls.Add(cp); |
rp.Dock = DockStyle.Fill; |
TabItem tab = new TabItem(); |
tab.Alignment = System.Drawing.ContentAlignment.BottomLeft; |
tab.Name = dtTabs.Rows[i].ItemArray[1].ToString(); |
tab.Text = dtTabs.Rows[i].ItemArray[1].ToString(); |
tab.DisplayStyle = DisplayStyle.ImageAndText; |
tab.TextImageRelation = TextImageRelation.ImageBeforeText; |
tab.ContentPanel.Controls.Add(rp); |
cp.StartRefresh(); |
tabMain.Items.Add(tab); |
} |
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
Telerik.WinControls;
using
Telerik.WinControls.UI;
namespace
RadGrid
{
public partial class RadForm1 : Telerik.WinControls.UI.RadForm
{
DataTable dtUserDetails = new DataTable();
public RadForm1()
{
InitializeComponent();
radGridView1.GridBehavior =
new GridBehavior();
}
private void RadForm1_Load(object sender, EventArgs e)
{
dtUserDetails.Columns.Add(
"ID");
dtUserDetails.Columns.Add(
"Name");
DataRow newRow;
for (int rowIndex = 0; rowIndex < 4; rowIndex++)
{
newRow = dtUserDetails.NewRow();
newRow[
"ID"] = rowIndex;
if (rowIndex == 0)
{
newRow[
"Name"] = "A";
}
else if (rowIndex == 1)
{
newRow[
"Name"] = "B";
}
else if (rowIndex == 2)
{
newRow[
"Name"] = "C";
}
else if (rowIndex == 3)
{
newRow[
"Name"] = "D";
}
else if (rowIndex == 4)
{
newRow[
"Name"] = "E";
}
else if (rowIndex == 5)
{
newRow[
"Name"] = "E";
}
dtUserDetails.Rows.Add(newRow);
}
dtUserDetails.AcceptChanges();
radGridView1.DataSource = dtUserDetails;
radTextBox1.DataBindings.Add(
"Text", dtUserDetails, "ID" );
radTextBox2.DataBindings.Add(
"Text", dtUserDetails, "Name");
}
private void radGridView1_SelectionChanged(object sender, EventArgs e)
{
//radGridView1.EndEdit();
if (dtUserDetails.GetChanges() != null)
{
if (MessageBox.Show("Do you want to save the changes", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
this.radGridView1.GridElement.BeginUpdate();
radGridView1.Relations.Clear();
dtUserDetails.AcceptChanges();
this.radGridView1.GridElement.EndUpdate();
//radGridView1.DataSource = null;
//radGridView1.DataSource = dtUserDetails;
}
}
}
private void radGridView1_ValueChanged(object sender, EventArgs e)
{
//radGridView1.EndEdit();
}
private void radGridView1_CurrentColumnChanged(object sender, CurrentColumnChangedEventArgs e)
{
}
private void radGridView1_RowsChanged(object sender, GridViewCollectionChangedEventArgs e)
{
if (dtUserDetails.GetChanges() != null)
{
if (MessageBox.Show("Do you want to save the changes", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
this.radGridView1.GridElement.BeginUpdate();
dtUserDetails.AcceptChanges();
//this.suppliersTableAdapter.Fill(this.nwindDataSet.Suppliers);
this.radGridView1.GridElement.EndUpdate();
//radGridView1.DataSource = null;
//radGridView1.DataSource = dtUserDetails;
}
}
}
}
public class GridBehavior : Telerik.WinControls.UI.BaseGridBehavior
{
protected override bool OnMouseDownLeft(MouseEventArgs e)
{
GridDataCellElement cell = this.GridControl.ElementTree.GetElementAtPoint(e.Location) as GridDataCellElement;
if (cell != null
&& !cell.Equals(
this.GridControl.CurrentCell)
&& cell.RowInfo.Equals(
this.GridControl.CurrentRow)
&& cell.ColumnInfo.ReadOnly)
{
this.GridControl.EndEdit();
}
try
{
return base.OnMouseDownLeft(e);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return true;
}
}
}
}