John Strano Technology Evangelist Sybase, Inc
John Strano Technology Evangelist Sybase, Inc
NET
Agenda
Overview of DataWindow .NET Windows Forms Demonstration Web Forms Demonstration Q&A Session
Introducing DataWindow .NET One component for data access and reporting Greatly reduces the amount of code you need to write in a .NET application Intuitive graphical user interface allows developers to be productive immediately Patented technology backed up by award-winning customer support Supports Microsoft Windows forms, Web forms, and Microsoft Windows Mobile-based Tablet PC applications
DataWindow .NET
Award Nomination
Database Support
Presentation Styles
Presentation Styles
Report Styles
Additional Features
DataWindow .NET
More Information
Over 1000 properties that can be accessed and manipulated at both design time and runtime Approximately 200 methods to access and control data and the DataWindow Lots of events for even greater control
ItemChanged, ItemError, SQLPreview, RowFocusChanged, etc.
DataWindow .NET
More Information
Edit Masks and formatting Computed Fields for client-side processing Supports SQL, stored procedures and external data sources Easy printing of DataWindows ( dwc.Print() ) Dynamic creation of DataWindows at runtime And much more!
Reduce Code
Example: Setting the Autosize Height on a Row
public void AutoSizeGrid() { // DataGrid should be bound to a DataTable for this part to // work. int numRows = ((DataTable)gridTasks.DataSource).Rows.Count; Graphics g = Graphics.FromHwnd(gridTasks.Handle); StringFormat sf = new StringFormat(StringFormat.GenericTypographic); SizeF size; // Since DataGridRows[] is not exposed directly by the DataGrid // we use reflection to hack internally to it.. There is actually // a method get_DataGridRows that returns the collection of rows // that is what we are doing here, and casting it to a System.Array MethodInfo mi = gridTasks.GetType().GetMethod("get_DataGridRows", BindingFlags.FlattenHierarchy | BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); System.Array dgra = (System.Array)mi.Invoke(gridTasks,null); // Convert this to an ArrayList, little bit easier to deal with // that way, plus we can strip out the newrow row. ArrayList DataGridRows = new ArrayList(); foreach (object dgrr in dgra) { if (dgrr.ToString().EndsWith("DataGridRelationshipRow")==true) DataGridRows.Add(dgrr); } // Now loop through all the rows in the grid for (int i = 0; i < numRows; ++i) { // Here we are telling it that the column width is set to // 400.. so size will contain the Height it needs to be. size = g.MeasureString(gridTasks[i,1].ToString(),gridTasks.Font,400,sf); int h = Convert.ToInt32(size.Height); // Little extra cellpadding space h = h + 8; // Now we pick that row out of the DataGridRows[] Array // that we have and set its Height property to what we // think it should be. PropertyInfo pi = DataGridRows[i].GetType().GetProperty("Height"); pi.SetValue(DataGridRows[i],h,null); // I have read here that after you set the Height in this manner that you should // Call the DataGrid Invalidate() method, but I haven't seen any prob with not calling it.. } g.Dispose(); }
DataGrid
DataWindow
Reduce Code
Example: Setting a Column Style to Checkbox
// code assumes you have a DataSet named myDataSet, a table named "EastCoastSales" and a DataGrid myDataGrid //STEP 1: Create a DataTable style object and set properties if required. DataGridTableStyle ts1 = new DataGridTableStyle(); //specify the table from dataset (required step) ts1.MappingName = "EastCoastSales"; // Set other properties (optional step) ts1.AlternatingBackColor = Color.LightBlue; //STEP 2: Create a string column and add it to the tablestyle DataGridColumnStyle TextCol = new DataGridTextBoxColumn(); TextCol.MappingName = "custName"; //from dataset table TextCol.HeaderText = "Customer Name"; TextCol.Width = 250; ts1.GridColumnStyles.Add(TextCol); //STEP 3: Create an int column style and add it to the tablestyle //this requires setting the format for the column through its property descriptor PropertyDescriptorCollection pdc = this.BindingContext [myDataSet, "EastCoastSales"].GetItemProperties(); //now created a formated column using the pdc DataGridDigitsTextBoxColumn csIDInt = new DataGridDigitsTextBoxColumn(pdc["CustID"], "i", true); csIDInt.MappingName = "CustID"; csIDInt.HeaderText = "CustID"; csIDInt.Width = 100; ts1.GridColumnStyles.Add(csIDInt); //STEP 4: Add the checkbox DataGridColumnStyle boolCol = new DataGridBoolColumn(); boolCol.MappingName = "Current"; boolCol.HeaderText = "Info Current"; //uncomment this line to get a two-state checkbox //((DataGridBoolColumn)boolCol).AllowNull = false; boolCol.Width = 150; ts1.GridColumnStyles.Add(boolCol); //STEP 5: Add the tablestyle to your datagrid's tablestlye collection myDataGrid.TableStyles.Add(ts1);
DataGrid DataWindow
Reduce Code
Example: Adding a Combo Box
DataGrid
// Step 1. Derive a custom column style from DataGridTextBoxColumn // a) add a ComboBox member // b) track when the combobox has focus in Enter and Leave events // c) override Edit to allow the ComboBox to replace the TextBox // d) override Commit to save the changed data // Step 2 - Use the combo column style // Add 1 col with combo style DataGridComboBoxColumn ComboTextCol = new DataGridComboBoxColumn(); ComboTextCol.MappingName = "custCity"; ComboTextCol.HeaderText = "Customer Address"; ComboTextCol.Width = 100; ts1.GridColumnStyles.Add(ComboTextCol); // Step 3 - Additional setup for Combo style // a) make the row height a little larger to handle minimum combo height ts1.PreferredRowHeight = ComboTextCol.ColumnComboBox.Height + 3; // b) Populate the combobox somehow. It is a normal combobox, so whatever... ComboTextCol.ColumnComboBox.Items.Clear(); ComboTextCol.ColumnComboBox.Items.Add("Chicago"); ComboTextCol.ColumnComboBox.Items.Add("Corvallis"); ComboTextCol.ColumnComboBox.Items.Add("Denver"); ComboTextCol.ColumnComboBox.Items.Add("Great Falls"); ComboTextCol.ColumnComboBox.Items.Add("Kansas City"); ComboTextCol.ColumnComboBox.Items.Add("Los Angeles"); ComboTextCol.ColumnComboBox.Items.Add("Raleigh"); ComboTextCol.ColumnComboBox.Items.Add("Washington"); // c) set the dropdown style of the combo... ComboTextCol.ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
DataWindow
Note: For data from a database even more code would be required!
Demonstration One
Windows Forms
Demonstration Two
Web Forms
Demonstration Four
dw-eXtreme.com Planner
Session Summary
Provided an overview of DataWindow .NET features Demonstrated how DataWindow .NET can be used in .NET Windows Forms applications Demonstrated how DataWindow .NET can be used in ASP.NET applications
DataWindow .NET
Resources
Newsgroup:
Forums.sybase.com sybase.public.datawindow.net http://www.sybase.com/support/newsgroups
Blogs:
http://www.teamsybase.net/blogs
Code Examples:
http://datawindownet.codexchange.sybase.com
Q&A