Create column in a Datagrid

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

ruca

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
 
E

Eliyahu Goldin

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
 
R

ruca

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,087
Members
48,773
Latest member
Kaybee

Latest Threads

Top