Telerik Forums
UI for WinForms Forum
7 answers
415 views
Hello,
how can I display my own combobox values in an unbound RadGridView when editing? The values are not specific to any columns or rows, in my scenario each cell can have completely different combobox values to offer (some can be even edited as free text or as numeric value).

Thanks in advance for your support
ZS
Jack
Telerik team
 answered on 23 Jul 2009
3 answers
265 views

Hi,

I am trying out the GridView in a programmatically manner, to build a hierarchy of an exception tree.  I don’t know if my approach is the best way, please tell if otherwise. The hierarchy is shown, but there are two issues I can’t figure out.

First, Due to the relationship all rows are shown as expandable! Only the root exception row and the InnerException row should be expandable. I have tried setting the ParentID to zero for those rows that are not expandable, but then they are not shown at all?

Second, In the expanded (nested) grid two tabs appear (named; table1 and table2), how do I remove/hide those?

Cheers, Frank

---------------------------- Sample Code -------------------------

  public class ExceptionExplorer
  {
    private static readonly string FIELD_EXCEPTIONID = "ExceptionID";
    private static readonly string FIELD_PARENTID = "ParentID";
    private static readonly string FIELD_NAME = "Name";
    private static readonly string FIELD_VALUE = "Value";

    public void ShowData(RadGridView gridView)
    {
      gridView.AutoGenerateHierarchy = false;
      gridView.AllowDrop = false;
      gridView.ShowGroupPanel = false;
      gridView.ShowNoDataText = false;
      
      try
      {
        gridView.Enabled = false;
        gridView.GridElement.BeginUpdate();
        gridView.Rows.Clear();

        List<Exception> exceptions = new List<Exception>();
        exceptions.Add(new ArithmeticException("ArithmeticException", new DataMisalignedException("DataMisalignedException", new global::System.NotSupportedException("NotSupportedException", new NotImplementedException("NotImplementedException")))));
        exceptions.Add(new ArgumentOutOfRangeException("ArgumentOutOfRangeException", new NullReferenceException("NullReferenceException", new global::System.NotSupportedException("NotSupportedException", new NotImplementedException("NotImplementedException")))));

        PrepareGridViewTemplate(gridView.MasterGridViewTemplate);
        int exceptionID = 0;
        foreach (Exception exception in exceptions)
        {
          ShowException(gridView.MasterGridViewTemplate, null, ref exceptionID, 0, exception.GetType().Name, exception);
        }
      }
      finally
      {
        gridView.GridElement.EndUpdate();
        gridView.Enabled = true;
      }
    }

    private void ShowException(GridViewTemplate gridviewTemplate, GridViewDataRowInfo parentRow, ref int exceptionID, int parentID, string exceptionTitle, Exception exception)
    {
      GridViewDataRowInfo exceptionRow = CreateGridRow(gridviewTemplate, parentRow, ++exceptionID, parentID, exceptionTitle, exception.GetType().FullName);

      parentID = exceptionID;
      GridViewTemplate childGridViewTemplate = CreateChildGridViewTemplate(gridviewTemplate);

      CreateGridRow(childGridViewTemplate, exceptionRow, ++exceptionID, parentID, "Message", exception.Message);
      CreateGridRow(childGridViewTemplate, exceptionRow, ++exceptionID, parentID, "Source", exception.Source);
      CreateGridRow(childGridViewTemplate, exceptionRow, ++exceptionID, parentID, "HelpLink", exception.HelpLink ?? string.Empty);
      CreateGridRow(childGridViewTemplate, exceptionRow, ++exceptionID, parentID, "TargetSite", exception.TargetSite == null ? string.Empty : exception.TargetSite.ToString());
      CreateGridRow(childGridViewTemplate, exceptionRow, ++exceptionID, parentID, "Stacktrace", exception.StackTrace);

      if (exception.InnerException != null)
      {
        ShowException(childGridViewTemplate, exceptionRow, ref exceptionID, parentID, "InnerException", exception.InnerException);
      }
    }

    private GridViewDataRowInfo CreateGridRow(GridViewTemplate gridviewTemplate, GridViewDataRowInfo parentRow, int exceptionID, int parentID, string nameColumn, string valueColumn)
    {
      //      GridViewDataRowInfo dataRow = gridviewTemplate.Rows.AddNew(/*parentRow*/); // Gives NullReferenceException...
      //      GridViewDataRowInfo dataRow = gridviewTemplate.Rows.AddNew();
      //      dataRow.Cells[FIELD_EXCEPTIONID].Value = exceptionID.ToString();
      //      dataRow.Cells[FIELD_PARENTID].Value = parentID.ToString();
      //      dataRow.Cells[FIELD_NAME].Value = nameColumn;
      //      dataRow.Cells[FIELD_VALUE].Value = valueColumn;
      // Gives NullReferenceException if cells are addressed through index/name ???

      GridViewDataRowInfo dataRow = gridviewTemplate.Rows[gridviewTemplate.Rows.Add(exceptionID, parentID, nameColumn, valueColumn)];
      dataRow.EnsureVisible();

      return dataRow;
    }

    private void PrepareGridViewTemplate(GridViewTemplate gridviewTemplate)
    {
      gridviewTemplate.AutoGenerateColumns = false;

      GridViewDataColumn gridColumn;
      gridviewTemplate.Columns.Add(gridColumn = new GridViewDataColumn(FIELD_EXCEPTIONID));
      gridColumn.IsVisible = false;
      SetColumnDefaults(gridColumn);

      gridviewTemplate.Columns.Add(gridColumn = new GridViewDataColumn(FIELD_PARENTID));
      gridColumn.IsVisible = false;
      SetColumnDefaults(gridColumn);

      gridviewTemplate.Columns.Add(gridColumn = new GridViewDataColumn(FIELD_NAME));
      gridColumn.Width = 200;
      SetColumnDefaults(gridColumn);

      gridviewTemplate.Columns.Add(gridColumn = new GridViewDataColumn(FIELD_VALUE));
      gridColumn.MinWidth = 200;
      SetColumnDefaults(gridColumn);

      gridviewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

      gridviewTemplate.AllowAddNewRow = false;
      gridviewTemplate.AllowDeleteRow = false;
      gridviewTemplate.AllowEditRow = false;
      gridviewTemplate.AllowColumnChooser = false;
      gridviewTemplate.AllowColumnReorder = false;
      gridviewTemplate.AllowDragToGroup = false;

      gridviewTemplate.ShowColumnHeaders = gridviewTemplate.Owner.MasterGridViewTemplate == gridviewTemplate;
      gridviewTemplate.ShowFilteringRow = false;
      gridviewTemplate.ShowGroupedColumns = false;
    }

    private GridViewTemplate CreateChildGridViewTemplate(GridViewTemplate parentTemplate)
    {
      GridViewTemplate childTemplate = new GridViewTemplate(parentTemplate.Owner);
      PrepareGridViewTemplate(childTemplate);

      GridViewRelation relation = new GridViewRelation(parentTemplate);
      relation.ChildTemplate = childTemplate;
      relation.RelationName = "ExceptionRelation";
      relation.ParentColumnNames.Add(FIELD_EXCEPTIONID);
      relation.ChildColumnNames.Add(FIELD_PARENTID);
      parentTemplate.Owner.Relations.Add(relation);

      parentTemplate.ChildGridViewTemplates.Add(childTemplate);

      return childTemplate;
    }

    private void SetColumnDefaults(GridViewDataColumn gridColumn)
    {
      gridColumn.HeaderText = gridColumn.FieldName;
      gridColumn.AllowFiltering = false;
      gridColumn.AllowGroup = false;
      gridColumn.AllowSort = false;
    }
  }

Jack
Telerik team
 answered on 23 Jul 2009
1 answer
243 views

Requirements

 

.Net Framework

3.5

Visual Studio version

2008 

Programming Language

C#


PROJECT DESCRIPTION
Only an example of using Linq to SQL with the Datagrid control

 

DataClasses1DataContext db = new DataClasses1DataContext();

 

 

var query = from p in db.Mst_Reconcilations

 

 

where p.Pat_Last_Name.StartsWith("A") && p.Pat_First_Name.StartsWith("C")

 

 

select new CustomerOrderResult

 

{

ID = p.ID,

AccNo = p.Acc_No,

CharNo = p.Chg_No,

FName = p.Pat_First_Name,

LName = p.Pat_Last_Name,

DOS = p.DOS

};

dataGridView1.DataSource = query;

dataGridView1.Columns[0].Visible =

false;

 

Vassil Petev
Telerik team
 answered on 23 Jul 2009
7 answers
196 views
What is the best way to prevent editing of primary key column(s) in the data grid?  I do not want the user to edit existing primary key column(s), however, I do want them to be able to edit the primary key column(s) when adding a new row.

Thanks for your help in advance,

James
Jack
Telerik team
 answered on 23 Jul 2009
3 answers
135 views
Hello,
  I am new to Telerik winforms controls. I have a RadGridView consisting of  a GridViewComboBoxColumn. I want to display images
within the combo-box, and when a selection is made, I want the selection text box of the combo-box to also display the image, not
just the text associated with it.

Also, I want to be able to implement the DblClick on the combo-box so that the images will rotate through the list
of images.

Can I accomplish this using a GridViewComboBoxColumn, or do I have to add a custom element to the grid cells?
I have been combing through the examples and forums, but have not been successful in implementing this functionality.

Thanks in advance,

Adriana

Victor
Telerik team
 answered on 23 Jul 2009
3 answers
140 views
Hi,

In a thread I working through our very slow Database (No its not SQL) and fill the Data in a DataTable. When a new row gets added to that DataTable I want to add the new row to the RadGrid as well. I thought iIwould increase the Rows.Count poperty and read the Row Info out of the DataTable in the Controls CellValuenNeeded event. The problem is that I get always an unhandlet exception sonner or later. When i remove the Event, the Datatable gets loaded correctly in the background.

Am I doing something wrong or do I use the wrong approach? Even locking has not helped me out.

Hope you can help me here.

Thanks
Victor
Telerik team
 answered on 23 Jul 2009
3 answers
175 views
I am new to Telerik and have a basic question. Does the Winform Listbox have the same feature set as the ASP Listbox? I am looking for item reordering and the ability to transfer from one listbox to another. Thanks...
Boyko Markov
Telerik team
 answered on 23 Jul 2009
1 answer
245 views
Hi,

Dont we have transition effect in rad rotator control.

I want something like transition.

Please find few effects from given link

http://tataindicom.com/

and

http://www.longtailvideo.com/players/jw-image-rotator/

I understand that web pages can achieve these using javascript or SWF files.
It will be great if same is available in winform applications.

Thanks & Best Regards,
Divyesh Chapaneri
Nick
Telerik team
 answered on 22 Jul 2009
1 answer
129 views
Hello Telerik Team,
I need to add functionality to dropdown buttons in our project (hook up Initialized event). However, when i tried to do so I have encountered problem with Layout of subclassed control. I have solved the problem by overriding following property
   public override string ThemeClassName
        {
            get
            {
                return "Telerik.WinControls.UI.RadDropDownButton";
            }
            set
            {
                base.ThemeClassName = "Telerik.WinControls.UI.RadDropDownButton";
            }
        }

is this valid solution? I have no idea why subclassed control got "wrong" layout. Is there any reference in documentation that would help me understand why this problem occured?



Nikolay
Telerik team
 answered on 22 Jul 2009
1 answer
186 views
I followed the instructions here: http://www.telerik.com/help/winforms/tree_designcontextmenus.html for adding a default context menu to a treeview. However, when I go to the treeview properties to set the radcontextmenu to the new menu I added, the drop down is blank (well it says none).

what exactly might I be doing wrong?
Boryana
Telerik team
 answered on 22 Jul 2009
Narrow your results
Selected tags
Tags
GridView
General Discussions
Scheduler and Reminder
Treeview
Dock
RibbonBar
Themes and Visual Style Builder
ChartView
Calendar, DateTimePicker, TimePicker and Clock
DropDownList
Buttons, RadioButton, CheckBox, etc
ListView
ComboBox and ListBox (obsolete as of Q2 2010)
Form
Chart (obsolete as of Q1 2013)
PageView
MultiColumn ComboBox
TextBox
RichTextEditor
PropertyGrid
Menu
RichTextBox (obsolete as of Q3 2014 SP1)
Panelbar (obsolete as of Q2 2010)
PivotGrid and PivotFieldList
Tabstrip (obsolete as of Q2 2010)
MaskedEditBox
CommandBar
PdfViewer and PdfViewerNavigator
ListControl
Carousel
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
VirtualGrid
Toolstrip (obsolete as of Q3 2010)
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
SplitContainer
Documentation
Map
DesktopAlert
CheckedDropDownList
ProgressBar
MessageBox
TrackBar
Rotator
SpinEditor
CheckedListBox
StatusStrip
CollapsiblePanel
LayoutControl
ShapedForm
SyntaxEditor
Wizard
TextBoxControl
Conversational UI, Chat
DateTimePicker
TabbedForm
CAB Enabling Kit
WaitingBar
GroupBox
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
FileDialogs
ColorDialog
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
NavigationView
BindingNavigator
RibbonForm
Styling
Barcode
PopupEditor
TaskBoard
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
BreadCrumb
ButtonTextBox
FontDropDownList
BarcodeView
Overlay
Security
LocalizationProvider
Dictionary
TreeMap
StepProgressBar
SplashScreen
Flyout
Separator
SparkLine
ToolbarForm
NotifyIcon
DateOnlyPicker
AI Coding Assistant
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
SpeechToTextButton
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?