But we can use reflection.
Here is an example how to change SearchView rows text color deppending on received data.
1. Add the following dll references to your project:
- Pivotal.CommonControls.dll
- CdcSoftware.Ios.UI.dll
2. Register "OnSearchCompleted" notification event handler:
[NotificationEvent("OnSearchCompleted", Table = "Support_Incident")] public void OnSupportIncidentSearchCompleted(object notifyParams) { ... }
3. Get DataGridView control via reflection.
CdcSoftware.Pivotal.CommonControls.ResultsViewControl resultsViewControl = searchView.SearchData.GetType().GetProperty("ResultsViewControl").GetValue(searchView.SearchData, null) as CdcSoftware.Pivotal.CommonControls.ResultsViewControl; if (resultsViewControl != null) { CdcSoftware.Pivotal.CommonControls.PivotalDataGridView dataGridView = resultsViewControl.GetType().GetField("_dataGridView", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(resultsViewControl) as CdcSoftware.Pivotal.CommonControls.PivotalDataGridView; }
4. Modify you want.
The full code example:
[NotificationEvent("OnSearchCompleted", Table = "Support_Incident")] public void OnSupportIncidentSearchCompleted(object notifyParams) { ISearchView searchView = ClientContext.ClientAPIService.GetActiveContentObject() as ISearchView; if (searchView != null) { //Get ResultsViewControl CdcSoftware.Pivotal.CommonControls.ResultsViewControl resultsViewControl = searchView.SearchData.GetType().GetProperty("ResultsViewControl").GetValue(searchView.SearchData, null) as CdcSoftware.Pivotal.CommonControls.ResultsViewControl; if (resultsViewControl != null) { //Get DataGridView control CdcSoftware.Pivotal.CommonControls.PivotalDataGridView dataGridView = resultsViewControl.GetType().GetField("_dataGridView", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(resultsViewControl) as CdcSoftware.Pivotal.CommonControls.PivotalDataGridView; //Attach RowPostPaint event dataGridView.RowPostPaint += new DataGridViewRowPostPaintEventHandler((object sender, DataGridViewRowPostPaintEventArgs e) => { CdcSoftware.Pivotal.CommonControls.PivotalDataGridView pivotalDataGridView = sender as CdcSoftware.Pivotal.CommonControls.PivotalDataGridView; if (dataGridView.Columns.Contains("Status_Id@Rn_Descriptor")) { //Color closed incidents string columnTextValue = Convert.ToString(pivotalDataGridView.Rows[e.RowIndex].Cells["Status_Id@Rn_Descriptor"].Value); if (columnTextValue.Contains("Closed")) { pivotalDataGridView.Rows[e.RowIndex].DefaultCellStyle.ForeColor = System.Drawing.Color.Red; } } }); } } }
Regards,
Max Shafranski