This is a migrated thread and some comments may be shown as answers.

Problems with RadGridView

4 Answers 164 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Francisco Ignacio
Top achievements
Rank 1
Francisco Ignacio asked on 27 Apr 2009, 06:01 PM
Hello:

    I recently upgraded to WindowsForms Q1 2009 and I'm having problems with radgridviews.

    I populate the gridview using bindingsources as DataSource, then managing the gridview Columns in the "MasterGridViewTemplate" (which ones are visible, sizes, etc).
    It worked correctly in the previous version I was using (Q1 2008 SP1), but now the gridview always displays all the columns and all of the have the same size.

Can anyone help me?
Thnks in advance.
Francisco.-

4 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 28 Apr 2009, 04:06 PM
Hi Francisco Ignacio,

Thank you for contacting us.

From the provided information I am not sure that I will be able to provide you with a solution. It seems that you most probably need to set AutoGenerateColumns to false. If this does not help, please be more specific about your exact code (or send us a code snppet). Thus I will be able to provide an advice how to change your code to work with our latest release.


Best wishes,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Francisco Ignacio
Top achievements
Rank 1
answered on 28 Apr 2009, 08:14 PM
Hi Nick:
  
    I feel quite embarrasing about this, because I looked for something like it in the "Properties Explorer" of visual studio without lucky before bothering you.
    I programaticaly added the sentence in the Designer Code, and it worked. Could it be a problem with the upgrade? something that didn't been updated in visual studio configuration?

    Is this a new feature of the Q1 2009 version? Because I just replaced the old Dlls with the new ones in the project and with this changes I'll have to fix every single radgrid I use in the entire project :(.

Thnks a lot.
Francisco.-


0
Fabien
Top achievements
Rank 2
answered on 29 Apr 2009, 08:39 AM
Hi,

I work with RadGridView like you, here is a sample of how I code
public static void GenerateGridViewVolumes(RadGridView pRadGridView) 
 
    // Start update 
    pRadGridView.GridElement.BeginUpdate(); 
     
    // Erase content 
    pRadGridView.MasterGridViewTemplate.AutoGenerateColumns = false
    pRadGridView.MasterGridViewTemplate.Columns.Clear(); 
    pRadGridView.MasterGridViewTemplate.GroupByExpressions.Clear(); 
    pRadGridView.MasterGridViewTemplate.SortExpressions.Clear(); 
    pRadGridView.MasterGridViewTemplate.AutoExpandGroups = false
     
    // Add Sort by expressions 
    ... 
     
    // Add Group by expressions 
    ... 
     
    // Add columns 
    ... 
     
    // Add Html View Definition 
    ... 
     
    // Add Conditionnal Colorization 
    ... 
     
    // Define Header Height 
    pRadGridView.GridElement.TableHeaderHeight = 20; 
     
    // End of update 
    pRadGridView.GridElement.EndUpdate(); 
 
public static void RefreshGridViewVolumes(RadGridView pRadGridView) 
 
    // Keep position of scrollbar 
    int VScrollBarValue = pRadGridView.GridElement.VScrollBar.Value; 
    int HScrollBarValue = pRadGridView.GridElement.HScrollBar.Value; 
 
    // Start update 
    pRadGridView.GridElement.BeginUpdate(); 
     
    // Clear rows 
    pRadGridView.MasterGridViewTemplate.Rows.Clear(); 
     
    // Set rows values 
    ... 
     
    // End of update 
    pRadGridView.GridElement.EndUpdate(); 
 
    // Retrieve position of scrollbar 
    try { pRadGridView.GridElement.VScrollBar.Value = VScrollBarValue; } 
    catch { } 
 
    try { pRadGridView.GridElement.HScrollBar.Value = HScrollBarValue; } 
    catch { } 

And how i add columns (for example a decimal column)
// Something 
GridViewDecimalColumn Something_Column = new GridViewDecimalColumn("Something""Something"
    HeaderText = "My header Text"
    FormatString = "{0:N0} Units"
    DataType = typeof(int), 
    TextAlignment = ContentAlignment.TopRight, 
    MinWidth = 70, 
    IsPinned = true
    DecimalPlaces = 0, 
    Minimum = 0, 
    ThousandsSeparator = true
    Step = 500 
}; 
pRadGridView.MasterGridViewTemplate.Columns.Add(Something_Column); 


Hope this sample will help you a bit.

Best regards,

Fabien



0
Nick
Telerik team
answered on 30 Apr 2009, 09:13 AM
Hello Francisco Ignacio,

RadGridView behavior for auto generated columns is changed at design time to correspond to MS DataGridView - not visible and always true. This brings better user experience when the data source is changed at design time --  the developer always gets feedback at design time that the data source is really changed and also its schema for the auto generated columns is updated. If you add manually some columns, they are also not deleted after changing the data source at design time.

When the data source is changed at run time you have full control over AutoGeneratedColumns property and you can set it to false.

Do not hesitate to write me back if you have further questions.

Sincerely yours,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Francisco Ignacio
Top achievements
Rank 1
Answers by
Nick
Telerik team
Francisco Ignacio
Top achievements
Rank 1
Fabien
Top achievements
Rank 2
Share this question
or