Search This Blog

Showing posts with label Telerik. Show all posts
Showing posts with label Telerik. Show all posts

Monday, January 21, 2013

Get parent row RadGridView Telerik

Telerik > Windows Forms > Get parent row RadGridView

Example: Get parent row RadGridView Telerik

Dim oParentRow As GridViewDataRowInfo = grd.CurrentRow.ViewInfo.ParentRow








Wednesday, January 16, 2013

Disable ContextMenu RadGridView Telerik

Telerik > Windows Forms > Disable ContextMenu RadGridView

AllowColumnHeaderContextMenu: Gets or sets a value indicating whether context menu is displayed when user right clicks on a data cell.
AllowCellContextMenu: Gets or sets a value indicating whether context menu is displayed when user right clicks on a data cell.

Example: Disable ContextMenu RadGridView Telerik

RadGridView1.MasterTemplate.AllowColumnHeaderContextMenu = False
RadGridView1.MasterTemplate.AllowCellContextMenu = False





Tuesday, January 15, 2013

Set font to RadPrintDocument Telerik (VB.NET)

Telerik > Windows Forms > Set font to RadPrintDocument

Example:

Dim RadPrintDocument1 As New RadPrintDocument
RadPrintDocument1.AssociatedObject = Me.RadGridView1
RadPrintDocument1.HeaderFont = New Drawing.Font("Tahoma", 18, FontStyle.Bold)
RadPrintDocument1.MiddleHeader = "Title"






Set time RadTimePicker Telerik (Windows Forms)

Telerik > Windows Forms > Set time RadTimePicker 

Example:

radTimePicker1.Value = DateTime.ParseExact("13:56", "HH:mm", null);






Monday, January 14, 2013

Delete rows with GridViewCommandColumn RadGridView C#

Telerik > Windows Forms > Delete Row RadGridView


Example: Add GridViewCommandColumn buton to RadGridView to delete current row
GridViewCommandColumn displays a button element.






using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls.UI;

namespace WindowsFormsApplication1
{
  public partial class Form1 : Form
 {
    public Form1()
   {
      InitializeComponent();
   }

   private void Form1_Load(object sender, EventArgs e)
  {
   // define text column
    GridViewTextBoxColumn colText = new GridViewTextBoxColumn();
  // define command colum
    GridViewCommandColumn colBtnDelete = new GridViewCommandColumn();
    colBtnDelete.DefaultText = "Delete";
    colBtnDelete.HeaderText = "Delete";
    colBtnDelete.Name = "Delete";
    colBtnDelete.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
    RadGridView1.MasterTemplate.Columns.AddRange(new   Telerik.WinControls.UI.GridViewDataColumn[] {colText,colBtnDelete});

// add rows to grid
   GridViewDataRowInfo rowInfo = new GridViewDataRowInfo(RadGridView1.MasterView);
   rowInfo.Cells[0].Value = "1";
   rowInfo.Cells[1].Value = "X"; // text for delete button
   RadGridView1.Rows.Add(rowInfo);

  rowInfo = new GridViewDataRowInfo(RadGridView1.MasterView);
  rowInfo.Cells[0].Value = "2";
  rowInfo.Cells[1].Value = "X";
  RadGridView1.Rows.Add(rowInfo);

  rowInfo = new GridViewDataRowInfo(RadGridView1.MasterView);
  rowInfo.Cells[0].Value = "3";
  rowInfo.Cells[1].Value = "X";
  RadGridView1.Rows.Add(rowInfo);
}

private void RadGridView1_CommandCellClick(object sender, EventArgs e)
{
   // handle CommandCellClick event
    GridCommandCellElement _cmd =(GridCommandCellElement)(sender);
    // if  text for delete button = X
    if ( _cmd.Value.ToString() == "X"
        RadGridView1.Rows.Remove(RadGridView1.CurrentRow); // remove current row
}
}
}






Export to Excel Hierarchial data in the RadGridView

Telerik > RadGridView

ExportToExcelML method exports an image of an element to Excel file

ExportHierarchy property set if child rows should be exported


Example:

ExportToExcelML excelExporter = new ExportToExcelML(radGridView);
excelExporter.ExportHierarchy = true;
excelExporter.RunExport(filePath);





Tuesday, January 8, 2013

Add Rows to RadGridView WinForms VB.NET

Telerik > RadGridView > Rows

GridViewRowInfo is the logical representation of a single row.

Examples

1. Add rows

You can add rows by creating an instance of GridViewDataRowInfo and adding it to the Rows collection of RadGridView

Dim rowInfo As New GridViewDataRowInfo(Me.RadGridView1.MasterView)
rowInfo.Cells(0).Value = "new row"
RadGridView1.Rows.Add(rowInfo)





Friday, January 4, 2013

Print RadGridView Telerik Windows Forms (VB.NET)

Telerik > Windows Forms > Print RadGridView

RadPrintDocument
Defines a reusable object that sends output to a printer and manages the whole printing process, when printing from an application

PrintPreviewDialog
Represents a dialog box form that contains a PrintPreviewControl for printing from a Windows Forms application.

AssociatedObject
 Gets or sets the object, associated with this document.

Print directly

Example:

Dim dialog As New PrintPreviewDialog
Dim RadPrintDocument1 As New RadPrintDocument
RadPrintDocument1.AssociatedObject = Me.RadGridView1
RadPrintDocument1.MiddleHeader = lblTitle.Text
RadPrintDocument1.MiddleFooter = "Page [Page #] of [Total Pages]"
RadPrintDocument1.RightFooter = "[Date Printed]"
dialog.Document = RadPrintDocument1
dialog.StartPosition = FormStartPosition.CenterScreen
dialog.ShowDialog()





Friday, November 30, 2012

How to change colums color to RadGridView (VB.NET)

Telerik > RadGridView > Cell Formatting

CellFormatting event is used to add formatting to grid cells

Because of UI virtualization in RadGridView, cell elements are created only for currently visible cells.
To prevent applying the formatting to other columns' cell elements all customization should be reset for the rest of the cell elements.
          
Example:
Change Forecolor in CellFormating Events
 

Imports Telerik.WinControls.UI
Imports Telerik.WinControls

Private Sub grd_CellFormatting(sender As System.Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles grd.CellFormatting
 
 If e.CellElement.ColumnInfo.Name = "total" Then
  e.CellElement.ForeColor = Color.Blue
 Else
  e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
 End If

End Sub






Friday, November 9, 2012

Disable Sorting for RadGrid Column, ASP net

Telerik > RadGrid > GridBoundColumn AllowSorting

Gets or sets a value indicating whether the sorting feature is enabled.

Example

Disable Sorting for RadGrid Column

GridColumn col = Grid.MasterTableView.Columns[4];
GridBoundColumn colB = (GridBoundColumn)col;
colB.AllowSorting = false;





Wednesday, October 24, 2012

How to add HyperLink Column to Telerik RadGrid Code Behind

Telerik > RadGrid > GridHyperLinkColumn





Each row in a Hyperlink column will contain a predefined hyperlink. This link is not the same for the whole column and can be defined for each row individually.

DataNavigateUrlFields: Gets or sets a string, representing a comma-separated enumeration of DataFields from the data source, which will form the url of the windwow/frame that the hyperlink will target.

DataNavigateUrlFormatString: Gets or sets a string, representing a comma-separated enumeration of DataFields from the data source, which will form the url of the windwow/frame that the hyperlink will target.
Example:
Add hyperlink column to RadGrid programmatically

RadGrid grd = new RadGrid();
GridHyperLinkColumn linkColumn = new GridHyperLinkColumn();
string[] fld = { "id" };
linkColumn.DataNavigateUrlFields = fld;
linkColumn.DataNavigateUrlFormatString = "Default.aspx?ID={0}";
linkColumn.HeaderText = "Id";
grd.Columns.Add(linkColumn);









Friday, October 5, 2012

Changing the size of Telerik RadComboBox DropDown

Telerik > RadComboBox > ComboBoxElement > DropDownWidth 


this.radComboBox1.ComboBoxElement.DropDownWidth = 200;
this.radComboBox1.ComboBoxElement.DropDownHeight = 600;





Thursday, October 4, 2012

Browse all rows and values RadGridView - Win Forms

Telerik > RadGridView > Browse all rows and values

Example:

C# Code
            for (i = 0; i <= RadGridView1.Rows.Count; i++)
            {
                for (j = 0; j <= RadGridView1.Columns.Count; j++)
                {
                    dynamic di = RadGridView1.Rows(i).Cells(j).Value;
                }
            }
            //or
             foreach (GridViewRowInfo _row in RadGridView1.Rows)
            {
                foreach (GridViewColumn _column in RadGridView1.Columns)
                {
                    dynamic di = _row.Cells(_column.Name).Value;
                }
            }

VB.NET Code

For i = 0 To RadGridView1.Rows.Count
  For j = 0 To RadGridView1.Columns.Count
   Dim di = RadGridView1.Rows(i).Cells(j).Value
  Next
Next
'or
For Each _row As GridViewRowInfo In RadGridView1.Rows
  For Each _column As GridViewColumn In RadGridView1.Columns
    Dim di = _row.Cells(_column.Name).Value
  Next
Next






How to set time to RadTimePicker Programmatically (ASP.NET)

Telerik > RadTimePicker > Set time

StartTime represents the starting time of the clock
EndTime represents  the time of the last clock item

Example : Set time  to RadTimePicker  code behind


RadTimePicker1.SelectedDate = DateTime.ParseExact("12:00", RadTimePicker1.TimeView.TimeFormat, null); // set default time

RadTimePicker1.TimeView.StartTime  = new TimeSpan(8, 60, 0); //start time
RadTimePicker1.TimeView.EndTime =  new TimeSpan(17,60, 0); // end time