Articles in this section

How to set Hex formatting of integer cell in WinForms GridControl?

Integer format as hex decimal


As per WinForms GridControl architecture, the hexadecimal format like {0x{0:X4} cannot be assigned by using the Format property. As we have used the IFormattable interface to convert the format to a string, the format has to be converted from a String.Format method. In the below sample, HexDecimal format to the integer cell has been set using the QueryCellInfo event.


this.gridControl1.QueryCellInfo += new GridQueryCellInfoEventHandler(gridControl1_QueryCellInfo);
void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
   if (e.ColIndex == 3 && e.RowIndex>0)
   {
       e.Style.Text = string.Format("0x{0:X4}", 255);
   }
}
Private Me.gridControl1.QueryCellInfo += New GridQueryCellInfoEventHandler(AddressOf gridControl1_QueryCellInfo)
Private Sub gridControl1_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
   If e.ColIndex = 3 AndAlso e.RowIndex>0 Then
    e.Style.Text = String.Format("0x{0:X4}", 255)
   End If
End Sub

The output is shown below

 

Shows the hexa decimal format in the grid column


Conclusion

I hope you enjoyed learning about how to set the Hex formatting of an integer cell in WinForms GridControl.


You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations and WinForms GridControl documentation, and how to quickly get started for configuration specifications.


For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.


If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied