Home Forums WinForms controls Xceed Grid for WinForms Setting .DataSource, but .Columns.Count = 0

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14051 |

    I’ve been using the grid control to good effect for about half a year now in a sizable project. I recently ran into an curious effect, though.

    In one particular form, I have a DataView object with a 9-column, 3-row DataTable in it. I attempt to set the grid’s .DataSource property to that view and then, immediately after, discover that the grid’s .Columns property has 0 columns in it, unlike all other cases I’ve seen. The behavior was 100% repeatable in this case; not sporadic.

    I gave up attempting to find the cause and simply deleted and recreated the control on the form. That resolved it.

    I’m not sure if there is a bug in the control or I simply used it incorrectly. Just wanted to add an instance to your knowledge base if this is a known issue.

    Thanks.

    – Jim Carnicelli

    Imported from legacy forums. Posted by Jim Carnicelli (had 2256 views)

    User (Old forums)
    Member
    Post count: 23064

    I’ve had this problem too, but I figured it out. The actual databinding happens when the GridControl itself needs the data for the first time (when painting). To force the databinding to happen immediately, do this: <pre>grid.DataSource = view;
    if (grid.BindingContext == null) grid.BindingContext = new BindingContext();</pre>

    Imported from legacy forums. Posted by Tommy (had 198 views)

    User (Old forums)
    Member
    Post count: 23064

    An interesting thought. I’ve added that to my code for good measure.

    What was very curious about all this, though, is that when I deleted and reinstantiated the grid control on my form, everything worked. Perhaps this technique is relevant, under the surface, though.

    Thanks a bunch for the feedback.

    -Jim Carnicelli

    Imported from legacy forums. Posted by Jim Carnicelli (had 3438 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.