Xamarin.Forms.DataGrid
Xamarin.Forms.DataGrid copied to clipboard
Horizontal Scroll Bar in DataGrid
How can we introduce Horizontal Scroll Bar in the DataGrid ? I have tried using ScrollView and Wrapped the DataGrid inside it but Its not Working.
<RelativeLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<StackLayout x:Name="GridViewLayoutStack" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width,Factor=1.0}" RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height,Factor=1.0}" VerticalOptions="FillAndExpand" Spacing="0" Padding="0,0,0,0">
<StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<ScrollView Orientation="Both" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<dg:DataGrid x:Name="DataGrid002" ItemsSource="{Binding ListeviewItemSource, Mode=TwoWay}" ColumnSpacing="0" Padding="0,0,0,0" HeaderBordersVisible="true" HeaderBackground="Silver" SelectionEnabled="true" BorderColor="Black" Margin="1" BorderThickness="1">
******* This one is working fine in my APP. Try it and let me know
Can you provide your sample here? Because the above code crashes the Application.
ok may i know what the error is ??
After adding the code Application just crashes down.
the above code that bharat posted here works for me, try double checking your code jatin, it may be that there is another reason why your application crashes.
@JatinRawat03 Xamarin.UWP does not support nested scroll view, so it will not work
the scroll view would be so nice if only it could display all the rows... on my side it cuts the last 4 remaining rows... I hope this can be more optimize
Edit: I've learned that it doesn't display all the rows since the scroll control in the datagrid is not being used along with scroll view... if only maybe the datagrid can have a horizontal scroll option... that would be really nice, so it would still look good even if it has a lot of columns
Hi!
There is a workaround to work in UWP. You need to define RowHeight="-1" for DataGrid
Hi! Is it possible to enable horizontal, but still keep it so that the column header is fixed in place / always visible? Using the layout @bharatkolla11 provided, the header scrolls out of viewport, too...
<ScrollView Orientation="Both">
<dg:DataGrid ItemsSource="{Binding Teams}" SelectionEnabled="True" SelectedItem="{Binding SelectedTeam}"
RowHeight="70" HeaderHeight="50" BorderColor="#CCCCCC" HeaderBackground="#E0E6F8"
PullToRefreshCommand="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}"
WidthRequest="600"
ActiveRowColor="#8899AA">
I am just learning how to get around in Visual Studios Xamarin Forms on a Mac. I have a lot of learning and have been stumbling along with all the help on the web. I have been working to read a CSV file of 1000 records with 37 columns and view the records in a table format. I have successfully been able to read the file with the file picker addin and display the contents with the free version of the Xamarin.forms.datagrid. After a lot of struggle I am able to display the results in a nice format and the records scroll very nicely. However, I can't get it to scroll the columns and have tried the suggested addition of the "scrollview" suggested above but apparently, it overwhelms the simulator as it never returns the grid whereas without the scroll view results are returned quickly.
So I was wondering if there are plans for any future enhancements to add a column scroll feature. Attached is the example I have been able to create from my datable of 1000 records but only the columns that will fit on the screen are visible and they do not scroll as does the records. I see that some of the commercial versions of Datagrid have this feature but I can't afford these for my purposes. The "free" version of the DevExpress version appears to be no longer supported. This free version Xamarin.forms.datagrid is a nice addition to Xamarin forms and would work great form my purpose if only I could get my grid to scroll the columns
<ScrollView Orientation="Both"> <dg:DataGrid ItemsSource="{Binding Teams}" SelectionEnabled="True" SelectedItem="{Binding SelectedTeam}" RowHeight="70" HeaderHeight="50" BorderColor="#CCCCCC" HeaderBackground="#E0E6F8" PullToRefreshCommand="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}" WidthRequest="600" ActiveRowColor="#8899AA">
This will crash in UWP project with this exception:
- [x] Exception = {"Error HRESULT E_FAIL has been returned from a call to a COM component."}