5 Answers, 1 is accepted
0
Accepted
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:
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
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
0
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
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.