- Home
- Forum
- Xamarin.Android
- controls inside cell
controls inside cell
Thank you for using Syncfusion products.
In SfDataGrid, you can put an image and text inside a GridCell by customizing the GridCell. You can add views inside the GridCell and layout it from the sample side based on your requirement. Please refer the below code example to know about “how to customize a GridCell”.
|
GridTextColumn customColumn = new GridTextColumn(); customColumn.UserCellType = typeof(GridImageCell); customColumn.MappingName = "ImageColumn"; public class GridImageCell : GridCell { private ImageView customerImage; private TextView textView; Bitmap bitmap;
public GridImageCell (Context context) : base (context) { customerImage = new ImageView (context); textView = new TextView(context) { Gravity = GravityFlags.Center }; this.CanRenderUnLoad = false; this.AddView (customerImage); this.AddView (textView); }
public MemoryStream LoadResource (String name) { MemoryStream aMem = new MemoryStream (); var assm = Assembly.GetExecutingAssembly (); var path = String.Format ("DataGrid.Resources.drawable.{0}", name); var aStream = assm.GetManifestResourceStream (path); aStream.CopyTo (aMem); return aMem; }
protected override void UnLoad () { if (this.Parent != null) (this.Parent as VirtualizingCellsControl).RemoveView (this); }
protected override void OnLayout (bool changed, int left, int top, int right, int bottom) { textView.Layout(0, 0, this.Width, 40); customerImage.Layout (0, 45, this.Width, this.Height - 40); }
public override void Draw (Canvas canvas) { base.Draw (canvas); textView.Text = "Image" + DataColumn.RowIndex; bitmap = (Bitmap)DataColumn.RowData.GetType ().GetProperty ("CustomerImage").GetValue (DataColumn.RowData); customerImage.SetImageBitmap (bitmap); }
protected override void Dispose (bool disposing) { if (bitmap != null) { this.customerImage.Dispose (); this.customerImage = null; this.textView = null; } base.Dispose (disposing); } |
Like this you can customize the GridCell to have more than one view inside based on your requirements and layout it inside the GridCell from the sample. For more details about customizing the GridCell in SfDataGrid, please refer the Formatting sample in our Demo samples.
Please let us know if this helps.
Regards,
Harikrishnan
Hi Guillaume,
To load a custom grid cell in SfDataGrid you need to create a column specifying the mapping name and the type of custom grid cell during creation itself. Hence this cannot be used for the dynamic columns as we do not know the property name that is bound with the column during the compile time.
Regards,
Prasanth
Hi Guillaume
We considered this 'LongPressEvent' as an feature request and a support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
Regards,
Dharmendar D.
- 5 Replies
- 5 Participants
-
RV Ricardo Vega
- Sep 17, 2015 03:09 PM UTC
- Jan 14, 2016 09:30 AM UTC