Two tables: Accounts and Companies
Accounts (AcctID, AcctNmbr, AcctName, CompID) -- AcctID is PK and CompID is Foreign Key from Companies.
Companies (CompID, CompName) -- CompID is PK.
Created a DataSet AcctDS with two Data Tables, Acct and Comp
Created a grid (GDBG) and I want to show the following in the Grid:
AcctNmbr AcctName Company
where Company is a ComboBox, whose values will be derived from the
Companies table. I only want to show CompName in the combo box.
DisplayMember is CompName from Comp Data Table and ValueMember is
CompID from Acct Data Table. So, a user can pick CompName from the
drop down combo box, but the actual value will be stored as CompID in
the Accounts table.
Can I just have a visual view of what I want to show (drag and drop items from the view) and then specify the column style (whether it is a combo box, text box etc.)? How do I drag and drop items on to the grid from the view?
ADAdministrator Syncfusion Team May 18, 2004 05:32 PM
You can do all this from the designer.
1) Create a Dataset with your two tables, Acct and Comp.
2) Drop a GridDataBoundGrid on your form, and set its DataSource to the Acct table.
3) In the GridBoundColumns collection of the grid, add AcctNmbr, AcctName, Company GridBoundColumns bound to the AcctNmbr, AcctName, CompID columns in the Acct table.
4) In the CompID GridBoundColumn, set the styleinfo.CellType to ComboBox, set the styleinfo.DataSource to the Comp table, set the styleinfo.DisplayMember to CompName, and the styleinfo.ValueMember to CompID.
You do not drag and drop in steps, but do choose everything from dropdowns in the property grid for the GridDataBoundGrid.
HBHarish BatraMay 19, 2004 06:20 AM
How do I perform step 3 and 4 from the designer (Vis Studio IDE)?
ADAdministrator Syncfusion Team May 19, 2004 06:33 AM
After setting the DataSource property for the grid, find the GridBoundColumns property in the gridDataBoundGrid''s property window. Then open up the collection editor, adding the columns you want. Make sure you set the MappingName property for each of the added columns as this is what tells the grid what columns are being used in this GridBoundColumn object. In the collection editor showing each of the GridBoundColumns, there is a StyleInfo property where you set the CellType, DataSource, DisplayMember and ValueMember for your special column.
HBHarish BatraMay 19, 2004 06:51 AM
I did that, however, no data is display when I run the application.
HBHarish BatraMay 19, 2004 06:58 AM
Just so you know, when I go to the Acct and Comp sqlAdapters respectively I can preview the data by righ clicking and doing "Preview Data". So I do get the data from the respective adapters. Since, I am doing every thing through the designer, do you think I might be doing something wrong?
Actually, in writing C# code for apps, when I write the code myself, I use the "fill" command to fill the dataset. But if I search for the word fill in code generated by the designer in this scenario, it doesn''t find the word fill. This is just a quick pointer.
ADAdministrator Syncfusion Team May 19, 2004 07:58 AM
You will not see the actual data at design time. You should be able to see the columns and headertext that you have set. (You see the same behavior with a Windows Forms DataGrid).
At runtime, you still have to call DataAdapter.Fill to get the data loaded (using the settings that you provided at design time).
Our GridGroupingControl actually does have a Preview verb that you can use at design time to load the data at design time, but you still have to use DataAdapter.Fill to load it at runtime.