Search
 Search
GET THE HOTEST NEWS ABOUT VISUAL WEBGUI.
CREATE LINE OF BUSINESS SILVERLIGHT APPLICATIONS IN NO TIME.
EVERY THING YOU NEED TO START DEVELOPING WITH VISUAL WEBGUI.
SEE VISUAL WEBGUI SHOW CASES FROM AROUND THE WORLD.
ALL THE RESOURCES YOU NEED TO START BUILDING VISUAL WEBGUI APPLICATIONS TODAY.
SHARE AND FIND VISUAL WEBGUI RESOURCES.
TALK WITH OTHER VISUAL WEBGUI DEVELOPERS.
 

 

SAP has chosen Visual WebGui for strategic web application, Mr. Saar of SAP explains why in an interview with with Jeremy Geelan at AJAX World.

Click on the video image to watch

SAP chosen VWG for strategic web application

SearchForum Home
  Core :: SDK (Visual WebGui Silverlight)   How do I...?  DataGridView wo...
 DataGridView woes
 
 8/15/2008 12:42:11 PM
DominionZA
18 posts


DataGridView woes
Hi all,

I am having a problem getting the DataGridView to listen to me. No matter what I do with column layout, the grid ignores me and simply auto creates columns when I databind.

Code...

grid.Columns.Clear();

// At this point, there are zero columns. 100%.

// Now creating one single column, just to test how this works.
Gizmox.WebGUI.Forms.DataGridViewColumn col = new DataGridViewColumn();
col.AutoSizeMode = Gizmox.WebGUI.Forms.DataGridViewAutoSizeColumnMode.NotSet;
col.DataPropertyName = "UserCode";
col.DefaultHeaderCellType = typeof(Gizmox.WebGUI.Forms.DataGridViewColumnHeaderCell);
col.Name = "UserCode";
col.Resizable = Gizmox.WebGUI.Forms.DataGridViewTriState.NotSet;
col.SortMode = Gizmox.WebGUI.Forms.DataGridViewColumnSortMode.Automatic;
col.Width = 100;

grid.Columns.Add(col);

// Grid now reflects that there is just ONE column. 100%.

// Lets bind the data.
DAL.VwCallsCollection calls = new Smartec.SmartLog.DAL.VwCallsCollection();
if (StatusComboBox.SelectedIndex == 0)
calls.Where(DAL.VwCalls.Columns.StatusID, SubSonic.Comparison.In, new ArrayList() { 1, 2, 3, 4, 5, 6 });
else
calls.Where(DAL.VwCalls.Columns.StatusID, StatusComboBox.SelectedValue);

calls.Load();

// This is where I am getting frustrated...
grid.DataSource = calls;
// grid.Columns.Count == 23 now. Why? I cleared all columns and manually added one. Why does the grid auto generate the columns? How do I turn this "feature" off? I want the control over column generation.

TIA
 8/15/2008 3:15:53 PM
palli
628 posts
1st


Re: DataGridView woes
There is a DGV.AutoGenerateColumns = False that you should try.

The default value seems to be True, and DGV created in the designer does not add this to the generated code.

When created in designer, I usually put this line in manually, after the designer has generated it's code, and after that it seems to stick.

Palli
 8/15/2008 3:44:55 PM
DominionZA
18 posts


Re: DataGridView woes

Thanks Palli. I found it in code eventually and doing the same as you. Strange that the property is not exposed in the designer.

Another question... If I can put it here.

I want to be able to set row colors based on the data that is bound to the row. But it is not working.

I have tried setting Row.DefaultCellStyle.BackColor = ... in both the DataBindingComplete and the RowsAdded events, but no change.
Any ideas? To set either an individual cell BackColor or the entire row. Will be happy with either.

TIA

 8/15/2008 3:52:10 PM
palli
628 posts
1st


Re: DataGridView woes
There is supposed to be an active issue about the AutoGenerateColumns and exposing it in designer. I have not seen it, but one of the core team member said that one of the developer was currently working on it.

As for coloring, I have done that sucessfully by handling the CellValueChanged event, in which case you set:
DGV.Rows(e.RowIndex).DefaultCellStyle.BackColor = Drawing.Color.Lime  or something

That handles changes done interactively. For preloaded data, that's not enough and you have to handle the CellFormatting event, in which case you set:
e.CellStyle.BackColor = Drawing.Color.Lime or some color.

Hope this helps,
Palli
 8/15/2008 3:54:25 PM
DominionZA
18 posts


Re: DataGridView woes
Thanks again Palli...

What I did discover, is my coloring works 100% if I render the form as a .wgx. If I render as .swgx then it does not do coloring and ignores my code outright.

Will play with your suggestions now and see what I come up with. Thanks again...
  Core :: SDK (Visual WebGui Silverlight)   How do I...?  DataGridView wo...

Visual Studop Partners

Copyright © 2005-2008 Visual WebGui®   Terms Of Use  Privacy Statement
Visual WebGui is copyright 2005-2008 by Gizmox