Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hi,

                                    I'm trying to bind a List<string> to a grid, so that there is just one column in the grid with that string's value in it.

                                    Currently what I do is set the DataSource to the property I want and then just declare a GridColumn without a FieldName. It shows up all the rows, but there are now values in the column.

                                    Thanks,
                                    Richard

                                0

                                Hi Richard,

                                Unless I am mistaken, you can use the column's DisplayMemberBinding property for this purpose. Please try the following code:

                                	
                                [XAML]
                                <dxg:GridControl Name="gridControl1"> <dxg:GridControl.Columns> <dxg:GridColumn Header="Value"> <dxg:GridColumn.DisplayMemberBinding> <Binding Path="RowData.Row" Mode="TwoWay"/> </dxg:GridColumn.DisplayMemberBinding> </dxg:GridColumn> </dxg:GridControl.Columns> <dxg:GridControl.View> <dxg:TableView Name="tableView1" AutoWidth="True"/> </dxg:GridControl.View> </dxg:GridControl>

                                Thanks,
                                Vito

                                0

                                Hi Vito,

                                Thanks for the quick reply, I also thought something like that would work, or binding to itself, but still just get the plain grid.

                                Here's what I have:

                                 <dxg:GridControl x:Name="gridItems" DataSource="{Binding Path=AllItems, UpdateSourceTrigger=PropertyChanged}">
                                            <dxg:GridControl.View>
                                                <dxg:TableView Name="view"
                                                               UseAnimationWhenExpanding="False"
                                                               NavigationStyle="None"
                                                               ShowGroupPanel="False"
                                                               BestFitMode="Smart" />
                                            </dxg:GridControl.View>
                                            <dxg:GridControl.Columns>
                                                <dxg:GridColumn Header="MyHeader">
                                                        <dxg:GridColumn.DisplayMemberBinding>
                                                            <Binding Path="RowData.Row"
                                                                     Mode="TwoWay" />
                                                        </dxg:GridColumn.DisplayMemberBinding>
                                                    </dxg:GridColumn>
                                            </dxg:GridControl.Columns>
                                        </dxg:GridControl>

                                0

                                Hi Richard,

                                It is very strange that this approach does not work for you. A similar code works as expected at my end. I am attaching a small sample project, which uses this approach. Please try it on your side, and let us know how it goes.

                                Thanks,
                                Vito

                                DXSample.zip
                                0

                                Hi Vito,

                                Not sure if it is because I'm running v2010 vol 2.8, and it looks like you're running the new Beta. Sorry, I see that the settings above were incorrect, my apologies.

                                I've attached the project that I've modified for 10.2.

                                Thanks

                                DevEx.rar
                                0

                                Hi Richard,

                                Thank you for the clarification.

                                In v10.2, please use the following binding expression to provide data for your column via DisplayMemberBinding:

                                	
                                [XAML]
                                <dxg:GridControl Name="gridControl1"> <dxg:GridControl.Columns> <dxg:GridColumn Header="Value"> <dxg:GridColumn.DisplayMemberBinding> <Binding Path="RowData.Row" RelativeSource="{RelativeSource Self}"/> </dxg:GridColumn.DisplayMemberBinding> </dxg:GridColumn> </dxg:GridControl.Columns> <dxg:GridControl.View> <dxg:TableView Name="tableView1" AutoWidth="True"/> </dxg:GridControl.View> </dxg:GridControl>

                                Please note, in this version, editing is not allowed when DisplayMemberBinding is used. In v10.2, it is used for display purposes only. If you need to implement editing as well, I recommend that you use unbound columns. I can provide you with more details, if needed.

                                Thanks,
                                Vito

                                0

                                Hi Vito, thanks, that seems to work fine. Going to upgrade tomorrow to V2011, so was a bit of a waste of time then, but thanks anyway.

                                0

                                You are welcome!

                                Thanks,
                                Vito

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners