Can't format datagrid programically

G

Guest

I have been trying for days to format the datagrid programmically.
Me.SqlDataAdapter1.Fill(Me.DataSet11
Dim tablestyle As New DataGridTableStyl
tablestyle.MappingName = "keywords
Dim column As New DataGridTextBoxColum
column.MappingName = "Keyword
column.HeaderText = "K
column.Width = 3
tablestyle.GridColumnStyles.Add(column
Me.DataGrid1.TableStyles.Add(tablestyle
The data grid always displays four columns with data from the corresponding table. I am just trying to have it display one column programmically. Does anyone have any suggestions on where I should look to try and fix the problem?
 
K

Ken Tucker [MVP]

Hi,

You probably have the tablestyle mapping name wrong. Try this.

tablestyle.MappingName = DataSet11.Tables(0).TableName

Ken
 
C

Cor

Hi Mike,

Can you make the following changes and look if that gives the result you
want?

Cpr

I have been trying for days to format the datagrid programmically.
Me.SqlDataAdapter1.Fill(Me.DataSet11)
Dim tablestyle As New DataGridTableStyle

tablestyle.MappingName = me.Dataset11.Tables(0).TableName
Dim column As New DataGridTextBoxColumn

column.MappingName = me.Dataset11.Tables(0).Columns(0).ColumnName
column.HeaderText = "K"
column.Width = 30
tablestyle.GridColumnStyles.Add(column)
Me.DataGrid1.TableStyles.Add(tablestyle)
The data grid always displays four columns with data from the
corresponding table. I am just trying to have it display one column
programmically. Does anyone have any suggestions on where I should look to
try and fix the problem?
 
A

anonymous

Ken,

That worked perfectly, but I don't understand why. I set a breakpoint to
figure out what name the piece code you gave me would come back with. The
name was the same as I had manually set. Do you have any ideas on what I am
missing. I really would like to understand.

Thank you for your help
 
C

Cor

Yes

That piece of code worked perfectly. After I set a breakpoint the only
difference was that "keywords" was "Keywords". I changed the code to have a
capital and it worked too. Do you know the cause of this problem?
 
C

Cor

Hi Mike,
What is the problem? I assume vb.net is not case sensitive. I must have
something that is set wrong or I have something set to purposely make things
case sensitive.
Please let me know.

As I also alway say but than others say that I am wrong.

It is on most (I think all) places where you have to place keywords between
" ".

I find it also not consistent.

Cor
 
C

CJ Taylor

VB.NET isn't case senstive... No one ever said that about String
Comparisons. =)

xxx = XXX only true with Option Compare Text

mike said:
Cor,

You wrote "Yes."

What is the problem? I assume vb.net is not case sensitive. I must have
something that is set wrong or I have something set to purposely make things
case sensitive.
 

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

Top