Hi
I am trying my first RadGridView bound to a bindingsource which is bound to a link to sql query result.
When I intially setup the RadGridView I set the datasource to an object which is the linq to sql datacontext class for that table.
I have formatted the grid to only display 2 of the many available fields and specially formated them size and header title.
However the formatting changes I have made do not appear and I get a generic 2 50 char cols. However in the designer it looks ok.
If I edit the designer.cs code and change the IsAutoGenerated to false my formatted cols appear but also two defaulted cols.
What am I doing wrong?
form.cs code
designer.cs code
Thanks Paul
I am trying my first RadGridView bound to a bindingsource which is bound to a link to sql query result.
When I intially setup the RadGridView I set the datasource to an object which is the linq to sql datacontext class for that table.
I have formatted the grid to only display 2 of the many available fields and specially formated them size and header title.
However the formatting changes I have made do not appear and I get a generic 2 50 char cols. However in the designer it looks ok.
If I edit the designer.cs code and change the IsAutoGenerated to false my formatted cols appear but also two defaulted cols.
What am I doing wrong?
form.cs code
| public partial class OrganizationsForm : Telerik.WinControls.RadForm |
| { |
| private CallDataClassesDataContext db; |
| public OrganizationsForm() |
| { |
| InitializeComponent(); |
| db = new CallDataClassesDataContext(); |
| var OrganizationQuery = from organ in db.Organizations |
| orderby organ.Name |
| select new |
| { |
| organ.OrganizationId, |
| organ.Name |
| }; |
| organizationBindingSource.DataSource = OrganizationQuery; |
| } |
| } |
designer.cs code
| private void InitializeComponent() |
| { |
| this.components = new System.ComponentModel.Container(); |
| Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn1 = new Telerik.WinControls.UI.GridViewDecimalColumn(); |
| Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn1 = new Telerik.WinControls.UI.GridViewTextBoxColumn(); |
| this.organizationBindingSource = new System.Windows.Forms.BindingSource(this.components); |
| this.radGridView1 = new Telerik.WinControls.UI.RadGridView(); |
| ((System.ComponentModel.ISupportInitialize)(this.organizationBindingSource)).BeginInit(); |
| ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit(); |
| ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterGridViewTemplate)).BeginInit(); |
| ((System.ComponentModel.ISupportInitialize)(this)).BeginInit(); |
| this.SuspendLayout(); |
| // |
| // organizationBindingSource |
| // |
| this.organizationBindingSource.DataSource = typeof(CallMaintain.Organization); |
| // |
| // radGridView1 |
| // |
| this.radGridView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247))))); |
| this.radGridView1.Cursor = System.Windows.Forms.Cursors.Default; |
| this.radGridView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); |
| this.radGridView1.ForeColor = System.Drawing.SystemColors.ControlText; |
| this.radGridView1.ImeMode = System.Windows.Forms.ImeMode.NoControl; |
| this.radGridView1.Location = new System.Drawing.Point(13, 13); |
| // |
| // |
| // |
| this.radGridView1.MasterGridViewTemplate.AllowColumnChooser = false; |
| this.radGridView1.MasterGridViewTemplate.AllowColumnResize = false; |
| this.radGridView1.MasterGridViewTemplate.AllowDeleteRow = false; |
| this.radGridView1.MasterGridViewTemplate.AllowDragToGroup = false; |
| gridViewDecimalColumn1.AllowGroup = false; |
| gridViewDecimalColumn1.AllowResize = false; |
| gridViewDecimalColumn1.DataType = typeof(int); |
| gridViewDecimalColumn1.FieldAlias = "OrganizationId"; |
| gridViewDecimalColumn1.FieldName = "OrganizationId"; |
| gridViewDecimalColumn1.FormatInfo = new System.Globalization.CultureInfo(""); |
| gridViewDecimalColumn1.HeaderText = "OrganizationId"; |
| gridViewDecimalColumn1.IsAutoGenerated = true; |
| gridViewDecimalColumn1.ReadOnly = true; |
| gridViewDecimalColumn1.UniqueName = "OrganizationId"; |
| gridViewDecimalColumn1.VisibleInColumnChooser = false; |
| gridViewDecimalColumn1.Width = 80; |
| gridViewTextBoxColumn1.AllowGroup = false; |
| gridViewTextBoxColumn1.FieldAlias = "Name"; |
| gridViewTextBoxColumn1.FieldName = "Name"; |
| gridViewTextBoxColumn1.FormatInfo = new System.Globalization.CultureInfo(""); |
| gridViewTextBoxColumn1.HeaderText = "Name"; |
| gridViewTextBoxColumn1.IsAutoGenerated = true; |
| gridViewTextBoxColumn1.UniqueName = "Name"; |
| gridViewTextBoxColumn1.VisibleInColumnChooser = false; |
| gridViewTextBoxColumn1.Width = 250; |
| this.radGridView1.MasterGridViewTemplate.Columns.Add(gridViewDecimalColumn1); |
| this.radGridView1.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn1); |
| this.radGridView1.MasterGridViewTemplate.DataSource = this.organizationBindingSource; |
| this.radGridView1.MasterGridViewTemplate.EnableGrouping = false; |
| this.radGridView1.Name = "radGridView1"; |
| this.radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.No; |
| this.radGridView1.ShowGroupPanel = false; |
| this.radGridView1.Size = new System.Drawing.Size(381, 150); |
| this.radGridView1.TabIndex = 0; |
| this.radGridView1.Text = "radGridViewPreview"; |
| // |
| // OrganizationsForm |
| // |
| this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
| this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
| this.ClientSize = new System.Drawing.Size(406, 276); |
| this.Controls.Add(this.radGridView1); |
| this.Name = "OrganizationsForm"; |
| this.Text = "Organizations"; |
| this.ThemeName = "Office2007Blue"; |
| ((System.ComponentModel.ISupportInitialize)(this.organizationBindingSource)).EndInit(); |
| ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterGridViewTemplate)).EndInit(); |
| ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit(); |
| ((System.ComponentModel.ISupportInitialize)(this)).EndInit(); |
| this.ResumeLayout(false); |
| this.PerformLayout(); |
| } |
Thanks Paul