fix column and row

6 posts, 1 answers
  1. Hengky
    Hengky avatar
    7 posts
    Member since:
    Sep 2018

    Posted 12 Sep 2018 Link to this post

    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 ....

  2. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3714 posts

    Posted 13 Sep 2018 Link to this post

    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.
  3. Hengky
    Hengky avatar
    7 posts
    Member since:
    Sep 2018

    Posted 13 Sep 2018 Link to this post

    Hello Dess, thanks for help.

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

     

    Thanks

  4. Hengky
    Hengky avatar
    7 posts
    Member since:
    Sep 2018

    Posted 13 Sep 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Dess can it be done by GUI ? 

     

  5. Hengky
    Hengky avatar
    7 posts
    Member since:
    Sep 2018

    Posted 13 Sep 2018 Link to this post

    Hello dess ... 

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

    Thanks before dess

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3714 posts

    Posted 17 Sep 2018 Link to this post

    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.
Back to Top