Hello,
I am creating application which need Grid Dynamic. I have Data Source from where randomly data will come with Various type datatype. like Date Time, String, Image.
So I have to generate Grid Accordingly. So how can I generate Columns Dynamically and add in Grid.
Hello Bhavin,
By default, the UltraGrid does just this. By setting UltraGrid.DataSource to your data source, the UltraGrid will read your data and create columns according to the data types it sees. As long as your data source has the proper data types set, the UltraGrid will automatically generate the appropriate columns.
If you wish to customize the columns further, you can access them via the InitializeLayout event, which will fire every time the DataSource is set. You can access them like so:
private void UltraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e) { UltraGridColumn intendedColumn = e.Layout.Bands[0].Columns["YourIntendedFieldName"]; }
You can also add columns not bound to your data source, for more info please take a look at Adding Unbound Columns.
Was there something more specific you are looking to do with UltraGrid columns?
Hi John ,
In My Case there is some specific Let me explain you. I have created Configuration utility. This Configuration Contains particular spec of Data which will be shown on UI.
Additionally for each Column there is Rules are created. Rule has Conditions and Actions.
Ex :- For Column A Rule is created like if column Value is < 5 then show that Cell Value in Red Color or Down Arrow image in cell .
As of I have both column Name data source and Actual Data Source Which will be displayed on UI.
I have to generate Columns dynamically according to configuration. That's why I was looking if I can create Ultra Grid Dynamically.
I hope you got my request.
I believe what you want to do here is check your conditions during InitializeRow and change the cell appearances accordingly. In the attached sample I've done just that. Please have a look at that sample and let me know if it enables you to affect cell appearances in the way you're looking for.