Create column in a Datagrid

  • Thread starter Thread starter ruca
  • Start date Start date
R

ruca

Hi,
I have two different questions to ask:

QUESTION 1:
Can I create dinamically a column in a datagrid? How?
I have a datagrid that must have 5 columns, but in some very special cases I
have to add another column. How can I do this in code?


QUESTION 2:
When I Debug my Web application, the debug is very slow. Changes line (step
by step) is slow.
Can I fix in anyway this problem?
I already try to see if any process is running, but I can't find anything
special.
Suggestions are welcome.
 
QUESTION 1:
I alredy get the solution. Here it is:
Dim col As New BoundColumn
col.HeaderText = [Header Label]
col.DataField = [FieldName]
col.Visible = True
col.ReadOnly = True
[datagrid name].Columns.Add(col)


QUESTION 2:
Waiting for your help
 
QUESTION 1:
Look at the help for DataGrid.Columns property and the example in the help
for DataGridColumnCollection.
A note from the help:
Although you can programmatically add columns to the Columns collection,
it is easier to list the columns statically and then use the Visible
property to show or hide the column.
Eliyahu
 
How can I access then to my dinamic column?

I try this, but doesn't work:

Dim str as String

str = Cstr(dg.SelectedItem.Cells(6).Text)

it says that it's out of range. I count the columns and I have 6 columns and
when I add dinamic column I'll have 7 columns, but I can't access the last
(it's dinamic)
How can I solve this?
 
Back
Top