Me
.RadGridView1.Rows.Clear()
Me
.RadGridView1.ColumnCount = 5
RadGridView1.Columns(0).HeaderText =
"Id."
RadGridView1.Columns(1).HeaderText =
"Name"
RadGridView1.Columns(2).HeaderText =
"Under Appeal"
RadGridView1.Columns(3).HeaderText =
"Terminated"
RadGridView1.Columns(4).HeaderText =
"#"
RadGridView1.Columns(1).Width = 100
RadGridView1.Rows.Add ( 1,
"John"
,
True
,
True
)
RadGridView1.Rows.Add ( 2,
"Mary"
,
True
,
False
)
RadGridView1.Rows.Add ( 3,
"Peter"
,
False
,
True
)
How do I get the radgridview to display checkboxes for boolean values for the last two columns? The columns get manually loaded.
Best regards
18 Answers, 1 is accepted
Do you do this in the designer?
If it is then when you add a Column to the Gird there should be a drop down to select what column type you would like
if you are adding them in code you would need to use the correct Column Class
http://www.telerik.com/help/winforms/gridview-columns-gridviewcheckboxcolumn.html
Me.RadGridView1.Rows.Clear()
Me.RadGridView1.ColumnCount = 5
RadGridView1.Columns(0).HeaderText = "Id."
RadGridView1.Columns(1).HeaderText = "Name"
RadGridView1.Columns(2).HeaderText = "Under Appeal"
RadGridView1.Columns(3).HeaderText = "Terminated"
RadGridView1.Columns(4).HeaderText = "#"
RadGridView1.Columns(1).Width = 100
RadGridView1.Rows.Add ( 1, "John", True, True )
RadGridView1.Rows.Add ( 2, "Mary", True, False )
RadGridView1.Rows.Add ( 3, "Peter", False, True )
Me.RadGridView1.ColumnCount = 5" T
his is what is adding the column rather then using this you can do the following, I'm not sure if there is a way to convert a column once it has been created.Me
.RadGridView1.Rows.Clear()
Dim
ID
As
New
GridViewDecimalColumn()
ID.Name =
"ID"
ID.HeaderText =
"Id"
RadGridView1.MasterTemplate.Columns.Add(ID)
Dim
Name
As
New
GridViewTextBoxColumn()
Name.Name =
"Name"
Name.HeaderText =
"Name"
Name.Width = 100
RadGridView1.MasterTemplate.Columns.Add(Name)
Dim
Under_Appeal as
New
GridViewCheckBoxColumn()
Under_Appeal.DataType =
GetType
(
Boolean
)
Under_Appeal.Name =
"Under_Appeal"
Under_Appeal.HeaderText =
"Under Appeal"
RadGridView1.MasterTemplate.Columns.Add(Under_Appeal)
Dim
Terminated as
New
GridViewCheckBoxColumn()
Terminated.DataType =
GetType
(
Boolean
)
Terminated.Name =
"Terminated"
Terminated.HeaderText =
"Terminated"
RadGridView1.MasterTemplate.Columns.Add(Terminated)
Dim
Hash
As
New
GridViewDecimalColumn()
Hash.Name =
"Hash"
Hash.HeaderText =
"#"
RadGridView1.MasterTemplate.Columns.Add(Hash)
RadGridView1.Rows.Add ( 1,
"John"
,
True
,
True
)
RadGridView1.Rows.Add ( 2,
"Mary"
,
True
,
False
)
RadGridView1.Rows.Add ( 3,
"Peter"
,
False
,
True
)
Thank you for writing.
As David mentioned, the code that you have provided does not show how you are adding the columns to your grid. If your column is added as GridViewCheckBoxColumn, you cannot change it afterwards. You need to either add the correct column initially or remove the undesired columns and add GridViewCheckBoxColumn instead.
I hope this helps.
Greetings,
Stefan
the Telerik team
Thanks for your kind reply. As I stated in my previous message David's message help me clarify the issue and I am happy moving to a different topic ... RadCharts :) . Your message is appreciated and acknowledged. Thanks for all your support. I am not usually developing win forms apps but I had this request so I never say "no" :-).
Best regards,
G
PS. By the way, I am already exploring Q1 2012 :-) Cheers.
Thank you for the nice words. I am glad that everything is OK.
Enjoy the new bits of Q1 2012 and let us know if you have any questions there.
Regards,
Stefan
the Telerik team
RadGridView1.Rows.Add ( 1, "John", True, True )
RadGridView1.Rows.Add ( 2, "Mary", True, False )
RadGridView1.Rows.Add ( 3, "Peter", False, True )
something like ...
RadGridView1.ChildRows.Add ( 1, "sugar", 2.00 )
RadGridView1.ChildRows.Add ( 1, "cake", 12.00 )
RadGridView1.ChildRows.Add ( 1, "butter", 3.00)
RadGridView1.ChildRows.Add ( 2, "cake", 12.00)
G
Thank you for your question.
In general, I would suggest to separate the different subjects into different threads, so they will be easier to find when looking for them.
In regards to your inquiry, first I would suggest that you get acquainted with our documentation concerning the different methods for Populating RadGridView with data and Binding to Hierarchical RadGridView. Both of these help sections will help you understand how RadGridView works, thus will help you choose the best approach for populating with data for your application.
Attached you can find a sample project demonstrating how to create a child template for your RadGridView, relate it with the MasterTemplate and add some row in it. I hope that you find this information helpful.
Regards,
Stefan
the Telerik team
G
Regards,
Stefan
the Telerik team
dgvSalaryReport.MasterTemplate.Templates[0].Rows.AddNew(); gvSalaryReport.MasterTemplate.Refresh(); dgvSalaryReport.MasterTemplate.Templates[0].Refresh();
but its not working for me.....the row count is increasing but rows not showing in the design .....please check the attached Picture
Hello, Ras Ran,
According to the provided information, I suppose that you have a hierarchy grid and want to add a new row to the first template (Templates[0]) collection. However, it is not clear enough whether you are using RadGridView in bound or unbound mode and how exactly the hierarchy is set up. Could you please elaborate?
Without knowing the exact setup, I can give you only general suggestions on how to add a new row to the child level.
If you set the DataSource property (bound mode) for each GridViewTemplate (master level and child level), in order to add a new record for the child template, it is necessary to add a new record to the DataSource collection that is being applied to the child GridViewTemplate. Since there is a relation (GridViewRelation) between the two GridViewTemplates indicating the child ID and the parent ID, it is important to specify the proper parent ID for the new record. Thus, the hierarchy row will be added to the respective parent row. If you have a bound grid and you try to add new row directly to the Rows collection you wouldn't be able to see the new row. A sample approach how the hierarchy is setup in this case is available in the "Setting the hierarchical grid in bound mode" section in the following help article: https://docs.telerik.com/devtools/winforms/controls/gridview/hierarchical-grid/binding-to-hierarchical-data-programmatically
If you use unbound mode and you add the rows directly to the Rows collection of the respective GridViewTemplate, it is just necessary to add a new row which cell's value for the parent ID points to the desired parent row. A sample approach for this approach is demonstrated in the "Hierarchical Grid in Unbound mode" section in the above-referred article.
I hope this information is useful. Should you have further questions please let me know.
Regards,
Nadya
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
hiii Nadya, please check the attached image.... i just enabled the property AllowAddNewRow ..... i just want to do this ( Add New Row ) as programmatically for Template Grid,
is there any solution for this ?
thanks and regards ,
RANEES
This My Code :GridViewTemplate template = new GridViewTemplate(); dgvSalaryReport.DataSource = null; dgvSalaryReport.DataSource = ds.Tables[0]; //DataTable template.DataSource = null; template.DataSource = dtForPaySlip; //DataTable template.EnableSorting = false; template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None; template.ShowRowHeaderColumn = false; template.AllowAddNewRow = true; template.EnableAlternatingRowColor = true; template.HorizontalScrollState = ScrollState.AlwaysShow; template.VerticalScrollState = ScrollState.AlwaysShow; dgvSalaryReport.MasterTemplate.Templates.Add(template); GridViewRelation relation = new GridViewRelation(dgvSalaryReport.MasterTemplate); relation.ChildTemplate = template;
Hello, RANEES,
I can not see the attached image. However, according to the provided code snippet, it seems that you have a bound RadGridView and you use DataTable for the child template. In order to add a new row programmatically to the child template (similarly as AllowAddNewRow works), it is necessary to add a new record to the DataSource collection that is being applied to the child GridViewTemplate, in your case add a new row to the DataTable. It is important to specify the proper parent ID for the new record. Thus, the hierarchy row will be added to the respective parent row.
I hope this helps. Please let me know if you need further assistance.
Regards,
Nadya
Progress Telerik
Тhe web is about to get a bit better!
The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.
hii Nadya.....How do get Row Count of current child template in CellEndEdit event
My Code : private void dgvSalaryReport_CellEndEdit(object sender, GridViewCellEventArgs e)
{
int rowIndex = Convert.ToInt32(e.RowIndex);
if (rowIndex > -1 && (e.Row.ViewInfo.Rows.Count - 1 == rowIndex))
{
e.Row.ViewTemplate.Rows.Add(3, empid, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
}
Hi, Ras Ran,
In the CellEndEdit event you have access to the affected data Row. Its HirerachicalLevel property indicates whether you are editing a child or a parent row. The Row.Parent property return the parent row from where you can get how many child rows a certain parent has. Please refer to the following code snippet:
public RadForm1()
{
InitializeComponent();
this.radGridView1.CellEndEdit += radGridView1_CellEndEdit;
}
private void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
{
if (e.Row.HierarchyLevel==1)
{
GridViewHierarchyRowInfo parentRow = e.Row.Parent as GridViewHierarchyRowInfo;
int childRowsCount = parentRow.ActiveView.Rows.Count;
}
}
private void RadForm1_Load(object sender, EventArgs e)
{
this.suppliersTableAdapter.Fill(this.nwindDataSet.Suppliers);
this.productsTableAdapter.Fill(this.nwindDataSet.Products);
radGridView1.DataSource = nwindDataSet.Suppliers;
GridViewTemplate template = new GridViewTemplate();
template.DataSource = nwindDataSet.Products;
radGridView1.MasterTemplate.Templates.Add(template);
GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate);
relation.ChildTemplate = template;
relation.RelationName = "SuppliersProducts";
relation.ParentColumnNames.Add("SupplierID");
relation.ChildColumnNames.Add("SupplierID");
radGridView1.Relations.Add(relation);
}
Feel free to modify and extend it in a way which suits your requirements best.
Should you have further questions please let me know.Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Тhe web is about to get a bit better!
The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.