This is a migrated thread and some comments may be shown as answers.

GridView missing properties

15 Answers 250 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Fawad
Top achievements
Rank 1
Fawad asked on 25 Mar 2011, 11:18 AM
Hi 

I recently switched from VB.NET to C# and I can not see UniqueName and  FieldAlias properties in GridView Q1 2011, is this a bad install or are they missing in C#? If they are missing, how can I change my code to get values I used to get from UniqueName?

Regards.

15 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 25 Mar 2011, 11:25 AM
Hello Fawad,

These properties are on the Column(s) please try the following:
void radGridView1_DataBindingComplete(object sender, GridViewBindingCompleteEventArgs e)
{
    foreach (var column in radGridView1.Columns)
    {
        MessageBox.Show("UniqueName: " + column.UniqueName + " FieldAlias: " + column.FieldAlias);
    }
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Fawad
Top achievements
Rank 1
answered on 25 Mar 2011, 11:32 AM
Thanks for quick reply Emanuel,

However, I am unable to see or set them in design mode, I'm porting a project from VB.NET to C# and have two VS2010 instances open, the difference is, older one was made in Q2, 2010 and now I am trying to design the same in Q1, 2011. But I can not see the properties of FieldAlias and UniqueName in designer. (by going to design mode, clicking on RadGrideView and hitting F4, then clicking on ellipsis against "Columns" ) When adding a column by clicking "Add" in design mode, I do not see UniqueName or FieldAlias properties in new RadGridView. Can you help please?


Regards.
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 25 Mar 2011, 11:42 AM
Hello again Fawad,

The UniqueName and the FieldAlias are both derprecated, that's why you cannot see them in the desgner, but from what i know, both the UniqueName and the FieldAlias have been replaced by the Name property of the column.

If you still need to use them like this you can just add them programmatically.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 25 Mar 2011, 11:43 AM
Hello,

These two properties are depricated in Q1 2011. You should use "Name", "FieldName", "HeaderText", and the other properties available in the designer.

Hope that helps
Richard
0
Fawad
Top achievements
Rank 1
answered on 25 Mar 2011, 11:47 AM
Thanks for the quick replies both of you, much appreciated. :-)

One little question, the textboxclomun in design mode is not letting me set "IsVisible" property to false, I want one column to be hidden initially, but designer is not letting me do it.  Can you please help?

Regards.
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 25 Mar 2011, 11:53 AM
Hello,

I can't replicate the issue of not setting the IsVisible property from the designer. This may just be a VS issue getting in a muddle and it may be worth just restarting your environment, and also trying it from the Smart Tag >> Open Property Builder. I've just tried it though and all works fine.

Let me know if you have further issues
Richard
0
Fawad
Top achievements
Rank 1
answered on 25 Mar 2011, 12:08 PM
Thanks Richard, the Tag >> Open Property Builder option worked, might be a VS glitch as restarting did not help either. 

I am marking this as solved but just a side question, is there any "upgrade wizard" for WinFroms by telerik as I don't seem to find any?

Regards.
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 25 Mar 2011, 12:15 PM
Hi,

There are several ways to upgrade your project and controls.
If you are using any of the obsolete controls still, then you can click on the smart tag for that control and choose Conversion Wizard which will guide you through upgrading from an old style control (such as a ListBox) to a new control (ListControl).

You can also go to the Tools folder inside your Telerik installation folder and run the "Project Upgrade Utility", or you can click on the Telerik > Rad Controls for WinForms menu in VS and choose "Upgrade Wizard" that will update the toolbox and assembly references.

Hope that helps but let me know if you have further questions
Richard
0
Fawad
Top achievements
Rank 1
answered on 25 Mar 2011, 12:25 PM
Thanks Richard, it helped a lot. Except for the last  option, as that's the one I can not see in my Telerik menu in VS 2010. But thanks anyway, marking it as solved. Going to bother you if anything else comes up. Cheers for now.

Regards.

0
Richard Slade
Top achievements
Rank 2
answered on 25 Mar 2011, 12:33 PM
Hello,

You might want to try closing VS and running the Telerik VS Extensions package to ensure you have all the options. You can find this at (for exmaple) C:\Program Files (x86)\Telerik\RadControls for WinForms Q1 2011\VSExtensions\VS2010

All the best
Richard
0
Fawad
Top achievements
Rank 1
answered on 25 Mar 2011, 02:52 PM
Thanks Richard, but TextBoxColumn is still not not invisible, I have used following techniques:

1. Restarted the VS2010.

2. Unticked the column's "IsVisible" property in Property builder.

3. Set it false in code-behind like this:

private void RdForm_Load(object sender, EventArgs e) // RadForm Load
       {
           MyRadGrid.Columns["MyID"].IsVisible = false;
       }

It hits it, but does not set the property to false.

Any other way I can hide the column at startup? 

Regards.
0
Emanuel Varga
Top achievements
Rank 1
answered on 25 Mar 2011, 02:53 PM
Hello,

Try setting it in the DataBindingComplete event.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Richard Slade
Top achievements
Rank 2
answered on 25 Mar 2011, 03:02 PM
Hello,

Please can you try this very basic exmaple. There are two columns and only the name column should be visible

Designer File (Form1.Designer.cs)
partial class Form1
{
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components;
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }
    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn1 = new Telerik.WinControls.UI.GridViewTextBoxColumn();
        Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn2 = new Telerik.WinControls.UI.GridViewTextBoxColumn();
        this.radGridView1 = new Telerik.WinControls.UI.RadGridView();
        ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit();
        this.SuspendLayout();
        // 
        // radGridView1
        // 
        this.radGridView1.BackColor = System.Drawing.SystemColors.Control;
        this.radGridView1.Cursor = System.Windows.Forms.Cursors.Default;
        this.radGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
        this.radGridView1.Font = new System.Drawing.Font("Segoe UI", 8.25F);
        this.radGridView1.ForeColor = System.Drawing.SystemColors.ControlText;
        this.radGridView1.ImeMode = System.Windows.Forms.ImeMode.NoControl;
        this.radGridView1.Location = new System.Drawing.Point(0, 0);
        // 
        // radGridView1
        // 
        gridViewTextBoxColumn1.FieldName = "Name";
        gridViewTextBoxColumn1.FormatString = "";
        gridViewTextBoxColumn1.HeaderText = "Name";
        gridViewTextBoxColumn1.Name = "Name";
        gridViewTextBoxColumn2.FieldName = "Id";
        gridViewTextBoxColumn2.HeaderText = "Id";
        gridViewTextBoxColumn2.IsVisible = false;
        gridViewTextBoxColumn2.Name = "Id";
        this.radGridView1.MasterTemplate.Columns.AddRange(new Telerik.WinControls.UI.GridViewDataColumn[] {
        gridViewTextBoxColumn1,
        gridViewTextBoxColumn2});
        this.radGridView1.Name = "radGridView1";
        this.radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.No;
        this.radGridView1.Size = new System.Drawing.Size(213, 172);
        this.radGridView1.TabIndex = 0;
        this.radGridView1.Text = "radGridView1";
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(213, 172);
        this.Controls.Add(this.radGridView1);
        this.Name = "Form1";
        this.Text = "Form1";
        ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit();
        this.ResumeLayout(false);
    }
    #endregion
    private Telerik.WinControls.UI.RadGridView radGridView1;
    private Telerik.WinControls.UI.RadGridView MasterTemplate;
}

Form1.cs
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;
  
  
    public partial class Form1 : Form
    {
        private List<Person> people = new List<Person>();
  
        public Form1()
        {
            InitializeComponent();
  
            people.Add(new Person(1, "Richard"));
            people.Add(new Person(2, "Bob"));
  
            this.radGridView1.AutoGenerateColumns = false;
            this.radGridView1.DataSource = people;
        }
    }
  
    public class Person
    
        public Person(int id, string name)
        { this.Id = id; this.Name = name; }
  
        public int Id
        { get; set; }
  
        public string Name
        { get; set; }
    }

This is built using the latest Q1 2011 release.
Hope this helps
Richard
0
Fawad
Top achievements
Rank 1
answered on 25 Mar 2011, 04:04 PM
Thanks Richard, I followed your example and went to designer code, manually changed the column's IsVisible to false and it worked. Strange as it refuses to work in design mode, even after restarting Windows 7.

Perhaps using RadForm instead of Windows Form is the issue? As yours is Windows Form and mine is RadForm, but it worked by manually changing the value, going to tell if the problem persists, thanks for the help, cheers.

Regards.
0
Richard Slade
Top achievements
Rank 2
answered on 25 Mar 2011, 04:13 PM
Ok, Glad that helped. Please let me know if you have further issues.
Regards,
Richard
Tags
GridView
Asked by
Fawad
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Fawad
Top achievements
Rank 1
Richard Slade
Top achievements
Rank 2
Share this question
or