471,350 Members | 1,928 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

How to set Grid properties?

I'd like to set certain grid properties generically. Meaning, I have a
method located in an independent class, pass in the particular grid and
have certain properties set. The problem is that I'm not sure how to
get the grid with those set properties back to the calling class. For
example:

DataGridOperation.cs:

public void BindDataGridTableSyle(DataGrid myGrid)
{
myGrid.TableStyles.Clear();
myGrid.TableStyles.Add(gridTableStyle);
}
Form1.cs:

DataGridOperation dgo = new DataGridOperation();
dgo.BindDataGridTableStyle(DataGrid1);
DataGrid1.DataSource = SomeDataTable;

The problem is the properties set in the above method are not coming
through in the grid. Do I need to return myGrid from the method? How
does that work because I'll then have DataGrid1 plus some other method.

Thanks,
Brett

Dec 20 '05 #1
4 1394
What you have should work. Where is gridTableStyle
defined???

public void BindDataGridTableSyle(DataGrid myGrid)
{
myGrid.TableStyles.Clear();
myGrid.TableStyles.Add(gridTableStyle);
}
--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.eggheadcafe.com/forums/merit.asp

"Brett Romero" <ac*****@cygen.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com... I'd like to set certain grid properties generically. Meaning, I have a
method located in an independent class, pass in the particular grid and
have certain properties set. The problem is that I'm not sure how to
get the grid with those set properties back to the calling class. For
example:

DataGridOperation.cs:

public void BindDataGridTableSyle(DataGrid myGrid)
{
myGrid.TableStyles.Clear();
myGrid.TableStyles.Add(gridTableStyle);
}
Form1.cs:

DataGridOperation dgo = new DataGridOperation();
dgo.BindDataGridTableStyle(DataGrid1);
DataGrid1.DataSource = SomeDataTable;

The problem is the properties set in the above method are not coming
through in the grid. Do I need to return myGrid from the method? How
does that work because I'll then have DataGrid1 plus some other method.

Thanks,
Brett

Dec 20 '05 #2
In DataGridOperation.cs. I don't see the mapping changes coming
through on the calling form.

Dec 20 '05 #3
Actally, the dataset I'm using as a source is empty and not returning
the column I need anyway. I'll adjust this and see what happens.

Thanks,
Brett

Dec 21 '05 #4
Actually, regardless of what the dataset returns, shouldn't the table
style take affect on the grid? Or, if a single mapped column is
missing, will that break the table style and it won't come through in
the grid?

Thanks,
Brett

Dec 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Martin Montgomery | last post: by
1 post views Thread by John Kraft | last post: by
6 posts views Thread by Ron M. Newman | last post: by
4 posts views Thread by Marc Gravell | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.