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

fix column and row

5 Answers 112 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hengky
Top achievements
Rank 1
Hengky asked on 13 Sep 2018, 04:23 AM

Hello All, 

is gridview possible to make fix row and column,

i need to make first column fix with default text "Type" 

and 2 fix rows "A" and "B" 

 

can this possible to apply ? 

 

Thanks ....

5 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Sep 2018, 08:24 AM
Hello, Hengky,           

If I understand your requirement correctly you are trying to assign a fixed text "Type" for the first column and fixed two values, "A" and "B", for the second column. For the first column you can use a simple GridViewTextBoxColumn and specify the default text for that cell. In addition, in the DefaultValuesNeeded event you can set this specific string as default value for the cell. As to the second column, since you have two options, I would recommend you to use a GridViewComboBoxColumn. You can find below a sample code snippet which result is illustrated in the screenshot: 

public RadForm1()
{
    InitializeComponent();
 
    GridViewTextBoxColumn typeColumn = new GridViewTextBoxColumn();
    radGridView1.MasterTemplate.Columns.Add(typeColumn);
    GridViewComboBoxColumn comboColumn = new GridViewComboBoxColumn();
    comboColumn.DataSource = GetData();
    comboColumn.ValueMember = "Id";
    comboColumn.DisplayMember = "Name";
    this.radGridView1.Columns.Add(comboColumn);
    this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
 
    this.radGridView1.DefaultValuesNeeded += radGridView1_DefaultValuesNeeded;
}
 
private object GetData()
{
    DataTable dt = new DataTable();
    dt.Columns.Add("Id", typeof(int));
    dt.Columns.Add("Name", typeof(string));
 
    dt.Rows.Add(1, "A");
    dt.Rows.Add(2, "B");
    return dt;
}
 
private void radGridView1_DefaultValuesNeeded(object sender, Telerik.WinControls.UI.GridViewRowEventArgs e)
{
    e.Row.Cells[0].Value = "Type";
}




If it is not the exact requirement that you are trying to achieve, please specify in details what is the goal that you are trying to accomplish. Thus, we would be able to think about a suitable solution and assist you further.

I hope this information helps. If you need any further assistance please don't hesitate to contact me.

Regards,
Dess
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Hengky
Top achievements
Rank 1
answered on 13 Sep 2018, 08:37 AM

Hello Dess, thanks for help.

youre the best .... i will try to applied this ..

 

Thanks

0
Hengky
Top achievements
Rank 1
answered on 13 Sep 2018, 10:25 AM

Dess can it be done by GUI ? 

 

0
Hengky
Top achievements
Rank 1
answered on 13 Sep 2018, 11:36 AM

Hello dess ... 

i need to make grid like this. it's possible... the blue area is fix 

Thanks before dess

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Sep 2018, 08:35 AM
Hello, Hengky,

According to the provided screenshot, it seems that RadGridView may be suitable for you. The first horizontal line represents the grid columns. The first vertical column may be a pinned row. The formatting can be achieved by using the ViewCellFormatting event. Thus, when the cell element is GridHeaderCellElement you can change the BackColor. For the rest of the cells, you should reset the style. Additional information about the formatting is available in the following help article: https://docs.telerik.com/devtools/winforms/gridview/cells/formatting-cells

I hope this information helps. If you need any further assistance please don't hesitate to contact me.

Regards,
Dess
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Hengky
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Hengky
Top achievements
Rank 1
Share this question
or