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

Add GridViewComboBoxColumn to exisiting column

4 Answers 122 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Won
Top achievements
Rank 1
Won asked on 05 Oct 2010, 01:49 AM
Hi! 
I am trying to implement GridViewComboBoxColumn on gridview for existing"DEPARTMENT_ID"
colum.
I tried below and it works fine, but it is adding another column on the gridview instead of replacing existing "DEPARTMENT_ID" column.
1. What should I change?
2. What property will remove a scroll bar on GridViewComboBoxColumn?

 
 With Me.rgvEmployee
            .Columns("EMP_ID").HeaderText = "EMP ID"

            Dim deptComboboxColumn As GridViewComboBoxColumn = New GridViewComboBoxColumn
            With deptComboboxColumn
                .UniqueName = "DeptColumn"
                .HeaderText = "Dept"
                .DataSource = From q In db.MST_DEPARTMENT _
                              Select q.DEPARTMENT_ID, q.DEPARTMENT_NM
                .ValueMember = "DEPARTMENT_ID"
                .DisplayMember = "DEPARTMENT_NM"
                .FieldName = "DEPARTMENT_ID"
                .Width = 200
            End With
            Me.rgvEmployee.Columns.Add(deptComboboxColumn)

        End With

4 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 05 Oct 2010, 05:27 AM
Hello Won,

1. The behavior you are describing is the normal behavior, you should just call .IsVisible = false; on the "old" "DEPARTMENT_ID" column, on the DataBindingComplete event;

2. Scroll bar in the combo's dropdown? or in the grid itself?

Hope this helps, if you have any more questions please do not hesitate to say so,

Best Regards,
Emanuel Varga
0
Won
Top achievements
Rank 1
answered on 05 Oct 2010, 02:35 PM
Emanuel. 

1. The behavior you are describing is the normal behavior, you should just call .IsVisible = false; on the "old" "DEPARTMENT_ID" column, on the DataBindingComplete event;
--> I knew that way, but the reason that I ask you is the added GridViewComboBoxColumn always goes to last. How do I move it to certain column? Let's say I want it to be 2nd column. 

2. Scroll bar in the combo's dropdown? or in the grid itself?
--> It worked with "Read only" property.

Lastly, I always appreciate for your answers.
Thanks.
0
Emanuel Varga
Top achievements
Rank 1
answered on 05 Oct 2010, 03:39 PM
Hello Won,

On the DataBindingComplete, just use:
C#
radGridView1.Columns.Move(radGridView1.Columns["ColumnToMove"].Index, newIndex);

or vb, i think:
radGridView1.Columns.Move(radGridView1.Columns("ColumnToMove").Index, newIndex)

Glad to help in any way i can.

Best Regards,
Emanuel Varga
0
Won
Top achievements
Rank 1
answered on 05 Oct 2010, 04:33 PM
Thanks. That works great.
Tags
GridView
Asked by
Won
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Won
Top achievements
Rank 1
Share this question
or