 |

DataGridViewColumns .NET 2.0 assembly (for VB.NET, C#, C++)
|
|
|
|
The DataGridView .NET 2.0 control seems a lot better than DataGrid .NET 1.x control. It provides a powerful and flexible way to display a data source. You can extend the DataGridView control in a number of ways to build custom behaviors into your applications. Although you can create your own types of cells the Windows Forms DataGridView control is mostly column-based, rather than cell-based. As a result, to attain most tasks, you have to work with the columns, not the cells themselves.
|
|
|
The DataGridView control is a new control presented in .NET framework 2.0 that replaces the DataGrid control. The DataGridView control provides increased amount of basic and advanced features that are not supported in the DataGrid .NET control. In addition, the structure and architecture of the DataGridView control makes it much easier to extend and customize than the DataGrid control.
DataGridViewColumns .NET 2.0 assembly from RustemSoft is a DataGridView Columns software package specifically designed for .NET 2.0 developers. The assembly allows you to use all strengths of the MS Windows .NET 2.0 forms DataGridView control without waiving the user interface elements your customers need.
|
|
|
|
Excellent work, guys! Thanks a lot!
Ryan J. Birnesser
Systems Software Designer/Programmer
Pioneer Pole Buildings, Inc.
Schuylkill Haven, PA
|
|
|
These Column classes are chock full of functionality that you wont find in the standard Microsoft .NET 2.0 DataGridView Columns, that make it easy to build professional and forcing user interfaces.
|
|
By using the assembly you can create your own set of DataGridViewColumn objects that defines custom column for the Windows Forms DataGridView control and add them to the GridColumnsCollection.
A column is an object that defines what the column looks and behaves like, including such things as color, font, and the presence of controls that will handle linked field in a database with the use of a Combo Box, a DateTime format Box and other control.
Also we have built .NET 2.0 code samples that describe the concepts and techniques that you can use to build DataGridView features into your applications.
|
|
|
|
The .NET 2.0 Framework includes six types of DataGridView column classes by default: DataGridViewButtonColumn, DataGridViewCheckBoxColumn, DataGridViewComboboxColumn, DataGridViewImageColumn, DataGridViewTextBoxColumn, and DataGridViewLinkColumn classes.
RustemSoft DataGridViewColumns dynamic link library contains the following additional DataGridView Columns:
|
 DataGridView Memo column
The RustemSoft DataGridViewMemoColumn gives you a useful Memo Field control, which presents an edit window when user selects a cell of the DataGridView Memo Column on .NET 2.0 DataGridView. This provides a pop-up memo field editor that you can call from your code at any time to let users edit the text in a memo field.
|
 |
|
This Memo field editor provides more flexibility by updating the memo field to be used in a .NET 2.0 DataGridView column.
The DataGridView Memo Column Memo field editor is useful for showing short document contents, like memos and emails.
When using the DataGridView Memo Column editor you are automatically provided with all general features, which any typical, contemporary word processor has.
|
| The following example creates a DataGridViewMemoColumn and adds it into the DataGridView layout.
|
| ' Set DataGridView Memo Column for Remark field
|
| Dim ColumnMemo As New DataGridViewMemoColumn
|
| .DataPropertyName = "Remark"
|
| .box.showCancelButton = False
|
| .box.Caption = "Edit Memo field text"
|
| DataGridView1.Columns.Add(ColumnMemo)
|
| // Set DataGridView Memo Column for Remark field
|
| DataGridViewMemoColumn ColumnMemo = new DataGridViewMemoColumn();
|
| ColumnMemo.DataPropertyName = "Remark";
|
| ColumnMemo.HeaderText = "Remark";
|
| ColumnMemo.box.showCancelButton = false;
|
| ColumnMemo.box.Caption = "Edit Memo field text";
|
| // Add ColumnMemo onto DataGridView layout
|
| DataGridView1.Columns.Add(ColumnMemo);
|
 DataGridView DateTimePicker column
The DateTimePicker Column is used to allow the user to select a date and time, and to display that date/time in your DataGridView.
|
 | |
You can limit the dates and times that can be selected by setting the MinDate and MaxDate properties.
DateTimePicker control allows you to display and collect dates and times formatted data. It allows you to display calendar information. The DateTime picker allows the user to view the days of the week around the day selected, or to view different months, as if flipping through a calendar. Another advantage of the DateTime picker is that it disallows invalid input.
The date-time picker consists of a text box with an accompanying calendar drop down. The user can input a date in several ways. Primarily, the user can enter a date by just typing it into the text box. Date-time picker validates the entry and disallows it if it is invalid. Second, the user can use the drop down to navigate to a date. Finally, the user can use the drop down and quickly click on today's Date to enter the current date, regardless of the month displayed in the drop down.
|
You can change the look of the calendar portion of the control by setting the CalendarForeColor, CalendarFont, CalendarTitleBackColor, CalendarTitleForeColor, CalendarTrailingForeColor, and CalendarMonthBackground properties.
The Format property sets the DateTimePickerFormat of the control. The default date Format is DateTimePickerFormat.Long. If the Format property is set to DateTimePickerFormat.Custom, you can create your own format style by setting the CustomFormat property and building a custom format string. The custom format string can be a combination of custom field characters and other literal characters. For example, you can display the date as "June 01, 2001 - Friday" by setting the CustomFormat property to "MMMM dd, yyyy - dddd".
box - one of the main properties of the DataGridViewDateTimePickerColumn class. The box is DateTimePicker object in selected cell. It gets the hosted box control that is an overridden instance of the DateTimePicker control.
|
 Syntax
DataGridViewDateTimePicker()
|
| The following example creates a DataGridViewDateTimeColumn and adds it into the DataGridView layout.
|
| ' Set datagrid DateTime Column for TimeFirst field
|
| Dim ColumnTime As New DataGridViewDateTimeColumn
|
| .DataPropertyName = "TimeFirst"
|
| ' Identify selected cell's DateTime format to edit
|
| .box.DateTimeFormat = DateTimeStencils.HHMM12
|
| ' Identify whole column DateTime format to display in each inactive column
|
| .DateTimeDisplayFormat = DateTimeStencils.HHMM12
|
| ' Specify Delimiter Character for the field
|
| .box.DefaultValue = New DateTime(2000, 5, 26, 11, 11, 11)
|
| ' Identify column selected cell back and foreground color
|
| .box.BackColor = Color.LightGray
|
| .box.ForeColor = Color.DarkRed
|
| ' Define cell warning color
|
| .box.ProblemColor = Color.LightPink
|
| ' Identify whole column back and fore colors
|
| .CellTemplate.Style.BackColor = Color.Ivory
|
| .CellTemplate.Style.ForeColor = Color.DarkBlue
|
| ' Define cell border style
|
| .box.BorderStyle = BorderStyle.None
|
| ' You may turn error messages off
|
| 'ColumnTime.box.ErrMessageVisible = False
|
| DataGridView1.Columns.Add(ColumnTime)
|
| // Set datagrid DateTime Column for TimeFirst field
|
| DataGridViewDateTimeColumn ColumnTime = new DataGridViewDateTimeColumn();
|
| ColumnTime.DataPropertyName = "TimeFirst";
|
| ColumnTime.HeaderText = "Time";
|
| // Identify selected cell's DateTime format to edit
|
| ColumnTime.box.DateTimeFormat = DateTimeStencils.HHMM12;
|
| // Identify whole column DateTime format to display in each inactive column
|
| ColumnTime.DateTimeDisplayFormat = DateTimeStencils.HHMM12;
|
| // Specify Delimiter Character for the field
|
| ColumnTime.box.DelimiterChar = ".";
|
| ColumnTime.box.DefaultValue = new DateTime(2000, 5, 26, 11, 11, 11).ToString();
|
| // Identify column selected cell back and foreground color
|
| ColumnTime.box.BackColor = Color.LightGray;
|
| ColumnTime.box.ForeColor = Color.DarkRed;
|
| // Define cell warning color
|
| ColumnTime.box.ProblemColor = Color.LightPink;
|
| // Identify whole column back and fore colors
|
| ColumnTime.CellTemplate.Style.BackColor = Color.Ivory;
|
| ColumnTime.CellTemplate.Style.ForeColor = Color.DarkBlue;
|
| // Define cell border style
|
| ColumnTime.box.BorderStyle = BorderStyle.None;
|
| // You may turn error messages off
|
| //ColumnTime.box.ErrMessageVisible = False;
|
| // Add ColumnTime onto DataGridView layout
|
| DataGridView1.Columns.Add(ColumnTime);
|
 Syntax
DataGridViewTimeUpDownColumn()
|
Up to 5 text fractions can be defined. By setting the DelimiterChar property up a delimiter symbol for the control can be specified. You can define the overall length of each text fraction and what kind of characters can be inserted in the fraction (alphanumeric, numeric only, etc.).
 Syntax
DataGridViewTextFractionsColumn()
|

To identify each text fraction you must set values of ten properties where settings of the fractions are stored. The first five properties (I_stFractionFormat, II_ndFractionFormat, IIIrdFractionFormat, IVthFractionFormat, and VthFractionFormat) specifies what characters can be inserted into the fraction. It accepts the following values of FractionFormats enumeration:
None - format is not assigned
Numeric - numeric characters (0-9) are acceptable only
Letters - letters (Aa-Zz) are acceptable only
Alphanumeric - alphanumeric characters (Aa-Zz0-9) are acceptable only
Punctuation - punctuation characters are acceptable only
Spaces - spaces are acceptable only
AnyCharacters - any characters are acceptable
The second five box specific properties (I_stFractionLength, II_ndFractionLength, IIIrdFractionLength, IVthFractionLength, and VthFractionLength) specifies overall fraction's length.
|
| The following example creates a DataGridViewTextFractionsColumn and adds it to the DataGridView layout.
|
| ' Set DataGridView Text Fractions Column for Phone field
|
| Dim MaskColumn As New DataGridViewFractionColumn
|
| .DataPropertyName = "Phone"
|
| ' selected cell has 3 fractions delimited by '-' char
|
| ' Define 1st fraction's parameters
|
| ' Numeric symbols only are acceptable for the fraction
|
| .box.I_stFractionFormat = FractionFormats.Numeric
|
| ' You can insert 3 symbols only into the first fraction
|
| .box.I_stFractionLength = 3
|
| ' Define 2nd fraction's parameters
|
| ' Numeric symbols only are acceptable for the fraction
|
| .box.II_ndFractionFormat = FractionFormats.Numeric
|
| ' You can insert 3 symbols only into the second fraction
|
| .box.II_ndFractionLength = 3
|
| ' Define 3rd fraction's parameters
|
| ' Numeric symbols only are acceptable for the fraction
|
| .box.IIIrdFractionFormat = FractionFormats.Numeric
|
| ' You can insert 4 symbols only into the third fraction
|
| .box.IIIrdFractionLength = 4
|
| ' Specify Delimiter Character for the field
|
| .box.DefaultValue = "911-911-0911"
|
| ' Identify column selected cell back and foreground colors
|
| .box.BackColor = Color.LightGray
|
| .box.ForeColor = Color.DarkRed
|
| ' Define cell warning color
|
| .box.ProblemColor = Color.LightPink
|
| ' Identify whole column back and foreground colors
|
| .CellTemplate.Style.BackColor = Color.WhiteSmoke
|
| .CellTemplate.Style.ForeColor = Color.Brown
|
| .CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleRight
|
| ' Define selected cell border style
|
| .box.BorderStyle = BorderStyle.Fixed3D
|
| ' Define selected cell's font
|
| .box.Font = New Font("Tahoma", 8, FontStyle.Bold)
|
| ' You may turn error messages off
|
| '.box.ErrMessageVisible = False
|
| ' You can specify an error message in your native language:
|
| '.box.ErrorMessage = "Veuillez écrire les nombres seulement!"
|
| DataGridView1.Columns.Add(MaskColumn)
|
| // Set DataGridView Text Fractions Column for Phone field
|
| DataGridViewFractionColumn MaskColumn = new DataGridViewFractionColumn();
|
| MaskColumn.DataPropertyName = "Phone";
|
| MaskColumn.HeaderText = "Phone";
|
| // selected cell has 3 fractions delimited by '-' char
|
| // Define 1st fraction's parameters
|
| // Numeric symbols only are acceptable for the fraction
|
| MaskColumn.box.I_stFractionFormat = FractionFormats.Numeric;
|
| // You can insert 3 symbols only into the first fraction
|
| MaskColumn.box.I_stFractionLength = 3;
|
| // Define 2nd fraction's parameters
|
| // Numeric symbols only are acceptable for the fraction
|
| MaskColumn.box.II_ndFractionFormat = FractionFormats.Numeric;
|
| // You can insert 3 symbols only into the second fraction
|
| MaskColumn.box.II_ndFractionLength = 3;
|
| // Define 3rd fraction's parameters
|
| // Numeric symbols only are acceptable for the fraction
|
| MaskColumn.box.IIIrdFractionFormat = FractionFormats.Numeric;
|
| // You can insert 4 symbols only into the third fraction
|
| MaskColumn.box.IIIrdFractionLength = 4;
|
| // Specify Delimiter Character for the field
|
| MaskColumn.box.DelimiterChar = "-";
|
| MaskColumn.box.DefaultValue = "911-911-0911";
|
| // Identify column selected cell back and foreground colors
|
| MaskColumn.box.BackColor = Color.LightGray;
|
| MaskColumn.box.ForeColor = Color.DarkRed;
|
| // Define cell warning color
|
| MaskColumn.box.ProblemColor = Color.LightPink;
|
| // Identify whole column back and foreground colors
|
| MaskColumn.CellTemplate.Style.BackColor = Color.WhiteSmoke;
|
| MaskColumn.CellTemplate.Style.ForeColor = Color.Brown;
|
| MaskColumn.CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
|
| // Define cell border style
|
| MaskColumn.box.BorderStyle = BorderStyle.Fixed3D;
|
| // Assign selected cell font to edit
|
| MaskColumn.box.Font = new Font("Tahoma", 8, FontStyle.Bold);
|
| // You may turn error messages off
|
| //ColumnFraction.box.ErrMessageVisible = False;
|
| // You can specify an error message in your native language:
|
| //ColumnFraction.box.ErrorMessage = "Veuillez écrire les nombres seulement!";
|
| // Add MaskColumn onto DataGridView layout
|
| DataGridView1.Columns.Add(MaskColumn);
|
| The following example creates DataGridViewDomainUpDownColumn object and adds it into the DataGridView layout. The column is populated from a DataTable object that belongs to a customized DataSet.
|
| ' Set DataGridView DomainUpDown Column for State field
|
| Dim DomainColumn As New DataGridViewDomainUpDownColumn
|
| .DataPropertyName = "State"
|
| ' Bind DomainColumn to SamplesDataSet.States table
|
| .DataSource = SamplesDataSet.States
|
| DataGridView1.Columns.Add(DomainColumn)
|
| // Set DataGridView DomainUpDown Column for State field
|
| DataGridViewDomainUpDownColumn DomainColumn = new DataGridViewDomainUpDownColumn();
|
| DomainColumn.DataPropertyName = "State";
|
| DomainColumn.HeaderText = "State";
|
| // Bind DomainColumn to SamplesDataSet.States table
|
| DomainColumn.DataSource = samplesDataSet.States;
|
| DomainColumn.DisplayMember = "State";
|
| // Add DomainColumn onto DataGridView layout
|
| DataGridView1.Columns.Add(DomainColumn);
|
 Syntax
DataGridViewNumericUpDownColumn()
|
 Syntax
DataGridViewPictureColumn()
|
| The following example creates a DataGridViewPictureColumn and adds it to the DataGridView layout.
|
| ' Define ColumnPicture Picture Column with WithEvents keyword
|
| Private WithEvents ColumnPicture As New DataGridViewPictureColumn()
|
| ' Set DataGridView Picture Column for Picture field
|
| ' The ColumnPicture Picture Column is defined above with WithEvents keyword to make
|
| ' the column object visible in the whole class scope. The WithEvents keyword indicates
|
| ' that a declared object variable refers to a class instance that can raise events.
|
| .DataPropertyName = "Picture"
|
| ' Specify path to a directory where image files are stored
|
| .PicturesPath = AppPath + "images\"
|
| DataGridView1.Columns.Add(ColumnPicture)
|
| |