Telerik Forums
UI for WinForms Forum
4 answers
210 views
I  have two problems occcurring in RadGriedView that has GriedViewComboboxCollumn as columns. Here there are:

1 . Creating Data: I set AutoGenerateColumns Property as false and I add two columns by a method (AddColumns) at runtime, each one column is a GridViewComboBoxColumn, defining their ValueMember = ID and DisplayMember = Name, then set datasource of first column, the second column datasource is set based on the select value of the first column. The second column datasource shows the items correctly, but when I select one item of combobox the grid display the ValueMember not the DisplayMember. Why ?


2. After creating Data (even not displaying the correct value), I save the datasource of grid in a IList and clean the gridview. Then I load this IList again in gridview, when I try to edit the value of the second column, the VS shows the message in the picture errortelerik.jpg. Thus, I cannot edit the row or add new row in the gridview.
How Can I handle this error? I already add the radGridView1_DataError event, but not solve the problem, I still not be able to edit the grid.



The code is here. What am I doing wrong?
namespace Example
{
    public partial class Form1 : Form
    {
        IList machineList = new ArrayList();
        IList SlotList1 = new ArrayList();
        IList SlotList2 = new ArrayList();
 
        IList datasource1 = null;
 
        public Form1()
        {
            InitializeComponent();
             
            this.radGridView1.MasterGridViewTemplate.AllowCellContextMenu = false;
            this.radGridView1.MasterGridViewTemplate.AllowColumnChooser = false;
            this.radGridView1.MasterGridViewTemplate.AllowColumnReorder = false;
            this.radGridView1.MasterGridViewTemplate.AllowDragToGroup = false;
            this.radGridView1.MasterGridViewTemplate.AutoGenerateColumns = false;
            this.radGridView1.MasterGridViewTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
            this.radGridView1.MasterGridViewTemplate.EnableGrouping = false;
            this.radGridView1.MasterGridViewTemplate.EnableSorting = false;
            this.radGridView1.MasterGridViewTemplate.ShowFilteringRow = false;
            this.radGridView1.ShowGroupPanel = false;
            this.radGridView1.ShowNoDataText = false;
             
            VO.Machine m1 = new VO.Machine();
            m1.IdMachine = 1;
            m1.MachineName = "Machine1";
 
            VO.Machine m2 = new VO.Machine();
            m2.IdMachine = 2;
            m2.MachineName = "Machine2";
 
            machineList.Add(m1);
            machineList.Add(m2);
 
            VO.Slot s1 = new VO.Slot();
            s1.IdMachineSlot = 1;
            s1.SlotName = "Slot1";
 
            VO.Slot s2 = new VO.Slot();
            s2.IdMachineSlot = 3;
            s2.SlotName = "Slot3";
 
            SlotList1.Add(s1);
            SlotList1.Add(s2);
 
            VO.Slot s3 = new VO.Slot();
            s3.IdMachineSlot = 2;
            s3.SlotName = "Slot2";
 
            VO.Slot s4 = new VO.Slot();
            s4.IdMachineSlot = 4;
            s4.SlotName = "Slot4";
 
            SlotList2.Add(s3);
            SlotList2.Add(s4);
        }
 
        private void clearForm()
        {         
            radGridView1.DataSource = null;
            radGridView1.Columns.Clear();
        }
 
        protected void AddColumns()
        {
            GridViewComboBoxColumn maquinaColumn = new GridViewComboBoxColumn("colMaquina");
            maquinaColumn.HeaderText = "Machine";
            maquinaColumn.ValueMember = "IdMachine";           
            maquinaColumn.DisplayMember = "MachineName";
            maquinaColumn.FieldName = "IdMachine";
             
            GridViewComboBoxColumn posicaoColumn = new GridViewComboBoxColumn("colPosicao");
            posicaoColumn.HeaderText = "Slot";
            posicaoColumn.FieldName = "SlotName";
            posicaoColumn.ValueMember = "IdMachineSlot";
            posicaoColumn.DisplayMember = "SlotName";
 
            radGridView1.Columns.Add(maquinaColumn);
            radGridView1.Columns.Add(posicaoColumn);
        }
 
        protected void FillColumns()
        {
            AddColumns();
 
            ((GridViewComboBoxColumn)this.radGridView1.Columns[0]).DataSource = machineList;
        }
 
        protected void saveDataSource()
        {
            datasource1= new ArrayList();
 
            for (int i = 0; i < radGridView1.RowCount; i++)
            {
                VO.MachineSlot ms = new VO.MachineSlot();               
                ms.IdMachine = int.Parse(radGridView1.Rows[i].Cells[0].Value.ToString());
                ms.MachineName = "Machine" + ms.IdMachine.ToString();               
                ms.IdMachineSlot = int.Parse(radGridView1.Rows[i].Cells[1].Value.ToString());
                ms.SlotName = "Slot" + ms.IdMachineSlot.ToString();
                datasource1.Add(ms);
            }
            MessageBox.Show("DataSource1 Saved");
        }
 
        private void doAction(int action)
        {
            switch (action)
            {
                case 0: // Build a new datasource
                    clearForm();                                           
                    datasource1 = null;
                    FillColumns();
                    break;
                case 1:
                    saveDataSource(); // Save datasource of radgridview
                    clearForm();
                    break;
                case 2:
                    clearForm();
                    radGridView1.DataSource = datasource1;
                    FillColumns();
                    break;
            }
        }
 
        private void radButton1_Click(object sender, EventArgs e)
        {
            doAction(0);
        }
 
        private void radButton3_Click(object sender, EventArgs e)
        {
            doAction(1);
        }
 
        private void radButton2_Click(object sender, EventArgs e)
        {
            doAction(2);
        }
 
        private void onCellEditorInitialized(object sender, GridViewCellEventArgs e)
        {
            if (e.Column.HeaderText == "Slot")
            {
                if (this.radGridView1.CurrentRow.Cells["IdMachine"].Value != DBNull.Value
                    && this.radGridView1.CurrentRow.Cells["IdMachine"].Value != null)
                {
                    RadComboBoxEditor editor = (RadComboBoxEditor)this.radGridView1.ActiveEditor;
                    RadComboBoxEditorElement editorElement = (RadComboBoxEditorElement)editor.EditorElement;
 
                    if (this.radGridView1.CurrentRow.Cells["IdMachine"].Value.ToString().Equals("1"))
                    {
                        editorElement.DataSource = SlotList1;
                    }
                    else
                        editorElement.DataSource = SlotList2;
 
                    editorElement.SelectedValue = null;
                    editorElement.SelectedValue =this.radGridView1.CurrentCell.Value;
                }
            }
        }
    }
}
 
namespace VO
{
    public class Machine
    {
        private int _id_maquina;
        private string _cd_maquina;
 
        public Machine()
        {
        }
 
        public int IdMachine
        {
            get { return _id_maquina; }
            set { _id_maquina = value; }
        }
        public string MachineName
        {
            get { return _cd_maquina; }
            set { _cd_maquina = value; }
        }
    }
 
    public class Slot
    {
        private int _idMachineSlot;
        private string _cdSlot;
 
        public Slot()
        {
        }
 
        public int IdMachineSlot
        {
            get { return _idMachineSlot; }
            set { _idMachineSlot = value; }
        }
        public string SlotName
        {
            get { return _cdSlot; }
            set { _cdSlot = value; }
        }
    }
 
    public class MachineSlot
    {
        private int _id_maquina;
        private string _cd_maquina;
        private int _idMachineSlot;
        private string _cdSlot;
 
        public MachineSlot()
        {
        }
        public int IdMachine
        {
            get { return _id_maquina; }
            set { _id_maquina = value; }
        }
        public string MachineName
        {
            get { return _cd_maquina; }
            set { _cd_maquina = value; }
        }
        public int IdMachineSlot
        {
            get { return _idMachineSlot; }
            set { _idMachineSlot = value; }
        }
        public string SlotName
        {
            get { return _cdSlot; }
            set { _cdSlot = value; }
        }
    }
}

Thanks.

Daniel
Top achievements
Rank 1
 answered on 20 Jul 2010
1 answer
126 views
Hi,

I have project that need to plot a S-N chart where X-axis is logarithmic scale, see attached image.

I see that I can use scatter chart to archive the result, however needs to swape x-axis and y-axis (where y become x and x become y).  anyone know is it possible to swape x-axis and y-axis or do when will RadChart support logarithmic scale on X-axis?

Thank you.
Giuseppe
Telerik team
 answered on 20 Jul 2010
2 answers
106 views

We have upgraded our Telerik controls from ‘Q3 2007 SP1’ to ‘Q3 2008 SP2’.

 

I am facing some issues while using this newer version:

 

  1. On Calendar control I don’t want day selections. Only date selections should be allowed. When we disable days, obviously they appear deactivated (with grey background). Please suggest some solution to make it appear similar to dates (with white background).

 

  1. Datetimepickers are allowing null values. User can select whole date and can just delete it. User should not allowed to edit the date values but should not be allowed to delete all contents.

 

  1. One more issue is regarding theme of raddropdownbutton. I want a theme with transparent background, when I tried to create it, there appears a slight white outline which is not required. How can i remove this white outline.
c mutex
Top achievements
Rank 1
 answered on 20 Jul 2010
1 answer
167 views
1:
In Q2 2010 there is no Method like EvaluateAggregate in SummaryItem. I need this method to implement SummaryAggregates like Sum / 4.0.

How can i implement this feature in Q2 ?

2:
Now i see ColumnIndexChanging is obsolete. I need column reordering only for columns with index > 3 for Example. How do i implement this now? --> Solved: Using Columns.CollectionChanging
Edit:
CollectionChanging/Changed solved not the problem. These events are fired 2 times for 1 column reordering (remove and add). in these events i dont see the new or the old index at the same time. Any solutions?

3:
How do i pin a SummaryItem?

4:
GridViewSummaryItem is not working anymore.

Example:

GridViewDataColumn column = new GridViewDecimalColumn("880", "880");
column.FormatString = "{0:N2}";
GridViewSummaryItem summaryItem = new GridViewSummaryItem(column.UniqueName, column.FormatString, GridAggregateFunction.Sum);
this.summaryRow.Add(summaryItem);

The Summary with 96 rows is 96 * 880. Min or Max is 880.

What is wrong here?

Alexander
Telerik team
 answered on 20 Jul 2010
1 answer
105 views
Hello All

I want to ask how can Multi column combo can be embeded inside the grid.

Thanks & regards
Neha Bharti
Jack
Telerik team
 answered on 20 Jul 2010
1 answer
144 views
I want to have my grid them my cells in read-only columns to use a different foreground color.  I was able to set this up in my theme using the IsReadOnly property of GridCellElement:

<XmlPropertySettingGroup>
    <PropertySettings>
        <XmlPropertySetting Property="Telerik.WinControls.VisualElement.ForeColor" Value="160, 160, 160" />
    </PropertySettings>
    <Selectors>
        <XmlClassSelector ElementClass="DataCell" AutoUnapply="False">
            <Condition xsi:type="XmlSimpleCondition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <Setting Property="Telerik.WinControls.UI.GridCellElement.IsReadOnly" Value="True" />
            </Condition>
        </XmlClassSelector>
    </Selectors>
</XmlPropertySettingGroup>

Then in the view cell formatting event, I added code to set each cell's IsReadOnly to match that of its column:

e.CellElement.IsReadOnly = e.CellElement.ColumnInfo.ReadOnly;

All of this works fine, but I get warnings that GridCellElement.IsReadOnly is obsolete.  Is there another property I should be using to set this up in my theme?  IsReadOnly seemed the best option in the visual style builder.

Thanks,
Rachel
Jack
Telerik team
 answered on 20 Jul 2010
7 answers
496 views
I wish to have a form with a gridview on one side and a panel with current record data on the other side (See attached file) so that I can edit data in the gridview or on the panel. Editing works fine, but problems appear on inserting.

Code behind update button is following:

        private void UpdateGridInfo(GridViewRowInfo currentRow)
        {
            if (currentRow == null)
                return;
            DB.Contract rowView = (DB.Contract)currentRow.DataBoundItem;
            if (rowView.ID == 0)
            {
                // insert
                DB.Contract contract = new DB.Contract();
                contract.RadioStationID = ((DB.vRadioStation)bsRadioStations2.Current).acSubject;
                ...
                App.ContractsDAL.DC.Contracts.InsertOnSubmit(contract);
            }
            else
            {
                // edit
                rowView.RadioStationID = ((DB.vRadioStation)bsRadioStations2.Current).acSubject;
                ...
            }
        }

        private void bUpdate_Click(object sender, EventArgs e)
        {
                UpdateGridInfo(gvContracts.CurrentRow);
                App.ContractsDAL.SubmitChanges();
                App.ContractsDAL.RefreshDC();
                bsContracts.DataSource = App.ContractsDAL.Get();
        }

When I click add a new row on the gridview and then edit data on the panel, I get exceptions for NOT NULL columns, foreign keys... when I try to submit changes, for example:
Cannot insert the value NULL into column 'RadioStationID', table 'RadioStations.dbo.Contracts'; column does not allow nulls. INSERT fails.
The statement has been terminated.

If I debug program, I see that contract.RadioStationID is set to correct value. At first it seems, that gridview automatically posts NULL values, but if I set columns to Nullable and delete relationships from database, everything works as it is supposed to.

How could I make this work without setting columns to Nullable and removing relationships?

Jack
Telerik team
 answered on 20 Jul 2010
1 answer
133 views
I have implemented an export routine using the RadGridView control.

It seemed to be working okay until Q22010.

Here is my structure:

I have a master template with two child templates. I want to read a row from the master and then read all rows from one child template and then read all the rows of the second child template. Both child templates are children of the master. I am referring to the child templates by index. One template caption is 'MVA' (index 0) and the other is 'P' (index 1). Let's assume there is only 1 of each.

Here is what happens:

if I have the 'MVA' tab selected and then export the MVA template is output twice and no 'P' template is output. However, if I have the 'P' tab selected the two 'P' records are output and no 'MVA'.

It looks as if I need to programmatically select first the 'MVA' tab and output the rows and then select the 'P' tab and output the rows.

I can't seem to reference the two sets of child rows directly.

Jack
Telerik team
 answered on 20 Jul 2010
1 answer
126 views
We got these errors when trying to upgrade our Q1 SP2 projects:

1. no 'VisualElement' property
GridViewRowInfo r = radGridView.Rows[i];
r.VisualElement.ForeColor = System.Drawing.Color.Red;

2. no 'CellElement' property
GridViewCellInfo gvci = radGridView.Rows[i].Cells[0];
GridCheckBoxCellElement gcbce = (GridCheckBoxCellElement)gvci.CellElement;

3. no 'Owner' property
var col = (GridViewDataColumn)cell.ColumnInfo;
col.OwnerTemplate.Owner;

Please help us to fix the above errors. Thanks in advance.

BR/shortie

Jack
Telerik team
 answered on 20 Jul 2010
1 answer
100 views
Hello Telerik,

I am looking into the just released Demo of Winforms UI components Q2 2010. On a fresh Windows XP setup (all windows updates installed) the provided demo application shows in Gridview  / Spreadsheet a simple undhandeld exception because "System.ArgumentException: Font 'Calibri' cannot be found." A quick search seems to indicate that Calibri is a font that came new with Vista and can be installed on XP by downloading and installing the MS PowerPoint Viewer 2007.

Maybe you want to fix this in future releases to provide the best possible first impression of your great components.

Regards,
Ralf
Alexander
Telerik team
 answered on 20 Jul 2010
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)
Chart (obsolete as of Q1 2013)
Form
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
Toolstrip (obsolete as of Q3 2010)
VirtualGrid
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
Documentation
SplitContainer
Map
DesktopAlert
CheckedDropDownList
ProgressBar
TrackBar
MessageBox
Rotator
SpinEditor
CheckedListBox
StatusStrip
LayoutControl
SyntaxEditor
Wizard
ShapedForm
TextBoxControl
Conversational UI, Chat
DateTimePicker
CollapsiblePanel
TabbedForm
CAB Enabling Kit
GroupBox
WaitingBar
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
ColorDialog
FileDialogs
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
Barcode
BindingNavigator
PopupEditor
RibbonForm
Styling
TaskBoard
Callout
ColorBox
PictureBox
FilterView
NavigationView
Accessibility
VirtualKeyboard
DataLayout
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Licensing
Localization
TimePicker
ButtonTextBox
FontDropDownList
BarcodeView
BreadCrumb
Security
LocalizationProvider
Dictionary
Overlay
Flyout
Separator
SparkLine
TreeMap
StepProgressBar
SplashScreen
ToolbarForm
NotifyIcon
DateOnlyPicker
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?