.Net DataGrid combobox Simple Sample

The sample introduces how to add the Combobox DataGrid Column Style into a DataGrid on your .NET Windows form.
The main idea of the sample is to provide you with a suggestion how to update values in other datagrid cells at a row when the current combobox cell has been updated. For this case when we need to update corresponding cells we are using the DataGrid ComboBoxColumn Leave event. When the user will leave changed combobox cell the event will have effect. In this example project when you change a value in Country column a suitable Capital name will be populated into Capital column and vise versa.

This combobox column style is not just a dropdown combobox, which appears when a datagrid cell becomes the current cell. The combobox DataGridColumnStyle automatically fills the text at the cursor with the value of its dropdown values list. As characters are typed, the component finds the closest matching item from the list and fills in the remaining characters.

The Simple Sample describes the Datagrid Combobox basic techniques only. To find out other attractive Datagrid Combobox Columns features please learn our Datagrid Columns sample projects. Also the code example gives hints how to deal with a database when you need update a set of records in the .NET datagrid interface and store the updates back into datasource database.
 

Download the Datagrid Combobox Simple Sample for VB.NET and C# that show how you can use the RustemSoft .NET DataGrid Combobox Column in Windows Forms.
 

VB.NET

 

' Set datagrid column styles
' Define comboCountry variable as a ComboBoxColumn column style object of DataGridComboBoxColumn class
Private WithEvents comboCountry As DataGridComboBoxColumn
' Define comboCapital variable as a ComboBoxColumn column style object of DataGridComboBoxColumn class
Private WithEvents comboCapital As DataGridComboBoxColumn

...........

' Set column styles
With .GridColumnStyles
' Set datagrid ComboBox Column Style for Country field
comboCountry = New DataGridComboBoxColumn(Dictionary, 0, 0, , , False)
.Add (comboCountry)
With .Item(0)
.MappingName = "Country"
.HeaderText = "Country"
.Width = 165
.NullText = String.Empty
End With

' Set datagrid ComboBox Column Style for Capital field
comboCapital = New DataGridComboBoxColumn(Dictionary, 1, 1, , , False)
.Add (comboCapital)
With .Item(1)
.MappingName = "Capital"
.HeaderText = "Capital"
.Width = 165
.NullText = String.Empty
End With

End With

...........

' "Country" datagrid cell has been left. Update corresponding "Capital" cell value in the current datagrid row
Private Sub comboCountry_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles comboCountry.Leave
Dim Capital As DataRow() = Dictionary.Select("Country='" + comboCountry.combo.Text + "'")
DataGrid1.Item(DataGrid1.CurrentRowIndex, 1) = Capital(0)(1)
End Sub

' "Capital" datagrid cell has been left. Update corresponding "Country" cell value in the current datagrid row
Private Sub comboCapital_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles comboCapital.Leave
Dim Country As DataRow() = Dictionary.Select("Capital='" + comboCapital.combo.Text + "'")
DataGrid1.Item(DataGrid1.CurrentRowIndex, 0) = Country(0)(0)
End Sub

 

C#

 

// Set column styles
// Define comboCountry variable as a ComboBoxColumn column style object of DataGridComboBoxColumn class
internal DataGridComboBoxColumn comboCountry;
// Define comboCapital variable as a ComboBoxColumn column style object of DataGridComboBoxColumn class
internal DataGridComboBoxColumn comboCapital;

...........

// Set column styles
// Set datagrid ComboBox ColumnStyle for Country field
comboCountry = (DataGridComboBoxColumn) new DataGridComboBoxColumn(ref Dictionary, 0, 0, true, false, false, DataGridComboBoxColumn.DisplayModes.ShowDisplayMember, 0);
comboCountry.Leave += new DataGridComboBoxColumn.LeaveEventHandler(this.comboCountry_Leave);
TblStyle.GridColumnStyles.Add(comboCountry);
TblStyle.GridColumnStyles[0].MappingName = "Country";
TblStyle.GridColumnStyles[0].HeaderText = "Country";
TblStyle.GridColumnStyles[0].Width = 165;
TblStyle.GridColumnStyles[0].NullText = string.Empty;

// Set datagrid ComboBox ColumnStyle for Capital field
comboCapital = (DataGridComboBoxColumn) new DataGridComboBoxColumn(ref Dictionary, 1, 1, true, false, false, DataGridComboBoxColumn.DisplayModes.ShowDisplayMember, 0);
comboCapital.Leave += new DataGridComboBoxColumn.LeaveEventHandler(this.comboCapital_Leave);
TblStyle.GridColumnStyles.Add(comboCapital);
TblStyle.GridColumnStyles[1].MappingName = "Capital";
TblStyle.GridColumnStyles[1].HeaderText = "Capital";
TblStyle.GridColumnStyles[1].Width = 165;
TblStyle.GridColumnStyles[1].NullText = string.Empty;

...........

// "Country" datagrid cell has been left. Update corresponding "Capital" cell value in the current datagrid row
private void comboCountry_Leave(object sender, System.EventArgs e)
{
System.Data.DataRow[] Capital = Dictionary.Select("Country='" + comboCountry.combo.Text + "'");
DataGrid1[DataGrid1.CurrentRowIndex, 1] = Capital[0][1];
}

// "Capital" datagrid cell has been left. Update corresponding "Country" cell value in the current datagrid row
private void comboCapital_Leave(object sender, System.EventArgs e)
{
System.Data.DataRow[] Country = Dictionary.Select("Capital='" + comboCapital.combo.Text + "'");
DataGrid1[DataGrid1.CurrentRowIndex, 0] = Country[0][0];
}

 

Learn more about DataGridColumns assembly
The assembly online documentation: http://rustemsoft.com/DataGridColumnsDoc/

Visual Basic News and Information Source - www.VBWire.com




Copyright ? 2001-2024 Rustemsoft LLC

 



 
 

 

 

RustemSoft Software Products

 

We are glad to represent our software products designed for MS Windows. The trial versions are available for free, so you can fully evaluate it before spending your money. RustemSoft develops software of several categories:

 

 

XML Converter smart data transformation system

Download Buy
 

Using XML Converter allows you to create XML document that will content the same data as your original MS Excel spreadsheet, MS Access database, Word document or csv/text file. XML Converter supports major databases such as ODBC, Oracle, MySQL and MS SQL Server. The resulting XML document will be built in strong compliance with XSL specifications. XML Converter allows you to create an XML database. This software gives you ability to generate an output as a set of XML tables. By using comprehensive interface you can adjust XML tags for final XML. Also this proved to be excellent because you can change the XSL style for XML output to what you wanted.

 
 

XML Converter two editions

Download Buy
 

XML Converter is available in two editions: Standard Edition and Professional Edition. The Standard edition is an economical solution for users who need to view the Data Source and Target XML document in order to better understand how to built a best XML representation. With the Standard Edition, users can browse the Data Source and Target XML file to generate XML output easily using a graphical user interface, without adding costly instrumentation.
XML Converter Professional Edition is a complete solution for developers who want the browse facilities provided in the Standard Edition PLUS special modules, which provide command-line interface. Using the Professional Edition you will be able to call XML Converter strictly from your own application, with no user interface, allowing you to convert Data Source to XML in batch mode.
XML Converter includes XML View, XML Tree, XML Grid, and XML Script modes for final XML output editing. These editing features are presented in well-known XMLFox free XML Editor. All XML Converter Editions packages include that freeware convenient XML/XSD Editor. XMLFox Editor is our guarantee of fast, friendly XML editing and validation that meet your XML programming needs.

 

 
 

XMLFox Advance XML/XSD Editor

Download Buy
 

Graphical XML editing and validation tool XMLFox Advance is XML/XSD editor for creating valid well-formed XML documents and/or XSD Schema. XMLFox Advance XML/XSD editor is the Windows based graphical tool for authoring, updating, exploring, well-formedness checking or validating XML documents. XMLFox Advance is an intuitive xml and xml schema(XSD) editor, allows the xml developer to create schemas and show a visual representation of what the xml document will look like for that schema.
XMLFox Advance Editor is a delimiter-aware XML data editor with markup-aware cut-and-paste operations, undo, rectangular selection, clear diagnostics and other innovative attractive tools to handle common XML/XSD editing tasks. Visual XML document editor, suited as a lightweight editor for document framework deployments. It features full XSD validation, but doesn't require a XSD (XML Schema Definition). XMLFox Advance includes XML View, XML Tree, XML Grid, and XML Script modes for editing.
XMLFox Advance is the tool for beginners to XSD schema (XML Schema Definition) as well as for professionals. It has visual Schema Tree representation that dynamically updates its XSD text. Those that need help in understanding schemas will find the Schema Tree inestimable, and developers maintaining other schemas will save hours of learning time with this XML editor. It is extremely configurable and fast enough. In XMLFox Advance you can output data to several other data format files. The Editor allows you export XML tables or whole XML to the following data files: TXT; convert into CSV (Comma Separated Value) file, convert into HTML page, create MS Access database, and create Excel file.

 

 
 

Skater .NET Obfuscator

Download Buy
 

RustemSoft presents Skater .NET Obfuscator, an obfuscation tool for .NET code protection. It implements all known software protection techniques and obfuscation algorithms.
If you would like periodically obfuscate your .NET products the Skater .NET Obfuscator is for you. RustemSoft is using the Skater for internal needs securing all RustemSoft .NET executables and assemblies. Its command-line version running in batch mode is much useful for your scheduled products updates. You have to assign settings for an assembly in GUI version first. Then the batch obfuscate task will use the settings.
Main features of Skater .NET Obfuscator:
Prohibits reverse engineering
Obfuscated application usually is not recompilable
Processes any .NET application, executable or assembly
Encrypts string constants
Compatible with any .NET framework (1.0, 1.1, 2.0, 3.0, and 3.5)
Control flow obfuscation stops decompilers and deobfuscators
Scrambles class names, method names, field names etc.

 

 
 

DataGridViewColumns .NET 2.0 assembly for MS VS.NET

Download Buy
 

We are presenting a software package for customizing your .NET 2.0 (Visual Studio 2005 and later) Windows Forms DataGridView Columns. The DataGridViewColumns .NET 2.0 assembly is DataGridView Columns software package specifically designed for .NET 2.x developers. The assembly allows you to use all strengths of the MS Windows .NET Forms DataGridView control without waiving the user interface elements your customers need. DataGridViewColumns dynamic link library contains the following DataGridView Columns: Combo (extended combobox), Memo column, DateTimePicker column. Also the assembly includes the formatting intelligent DateTimeColumn, NumericColumn, TextFractionsColumn, MaskedTextBox column controls that can mask the date, time, numbers as well as the text fractions. It gives you ability to manage the IP Address, SS#, Phone numbers, etc., and checks the validation, and automatically set the delimiter location. These Column classes are chock full of functionality that you wont find in the standard Microsoft .NET 2.x DataGridView Columns, that make it easy to build professional and forcing user interfaces.

 
 

DataGridColumns .NET assembly for MS VS.NET

Download Buy
 

We are presenting a software package for customizing your .NET Windows Forms DataGrid Columns. The DataGridColumns .NET assembly is a DataGrid Columns Styles software package specifically designed for .NET developers. The assembly allows you to use all strengths of the MS Windows .NET Forms DataGrid control without waiving the user interface elements your customers need. DataGridColumns dynamic link library contains the following DataGrid Column Styles: combobox, XPButton column Style, Memo column Style, Button column Style, DateTimePicker column Style. Also the assembly includes the formatting intelligent DateTimeColumn, NumericColumn, TextFractionsColumn style controls that can mask the date, time, numbers as well as the text fractions. It gives you ability to manage the IP Address, SS#, Phone numbers, etc., and checks the validation, and automatically set the delimiter location.

 
 

ASP DataGridColumns assembly for MS VS.NET

Download Buy
 

One of the most permanent challenges in designing user interfaces is figuring out how to display large amounts of data efficiently and intuitively without bewildering the user. The problem becomes particularly thorny when the interface must give the ability to easily update and store the data that the user needs to modify. We are presenting a software package for customizing your ASP .NET DataGrid server control's Columns. The ASP DataGridColumns .NET assembly from RustemSoft is a DataGrid Columns software package specifically designed for ASP .NET developers. The assembly allows you to use all strengths of the .NET DataGrid server control without waiving the user interface elements your customers need.

 
 

Sonswish - Oracle database browser

Download Buy
 

Sonswish Oracle database browser is the Windows based graphical tool for database navigation, data updating, exploring, table relationships checking or validating Oracle database. Sonswish is an intuitive Oracle browser, allows the Oracle developer to create Oracle database objects (such as tables, views, procedures and so on) and show a visual representation of table relationships for that Oracle database.
Sonswish browser is a universal Oracle database browser with data updating operations, record filtering, printing, data format validation and other innovative attractive tools to handle common Oracle database browsing tasks. Sonswish allows to browse both structures and contents of databases managed by Oracle DBMS. Despite the fact that Sonswish cannot be positioned as a database's control application, our product has a number of most important features of database control application.
Sonswish allows to insert, delete, and update data records into database tables, remove whole tables. Furthermore, Sonswish provides interface to execute SQL statements of any complexity and for any purpose. Sonswish presents database as a hierarchical tree structure representation of all objects that belong to your Oracle database. A user can browse table structure, table indexes, primary keys, foreign keys, constraints and other table's objects. The software allows you export Oracle database tables/views to the following data files: txt, csv, html, mdb, Excel.

 

 
 

VB .NET and C# samples

 

Everyone was a beginner once. The faster we feed new people with good information, the faster they will become good members of the ".NET World". Here you can find some useful VB and C# examples. These sets of samples contain several high quality examples. These code samples show you how to work with comboboxes on Windows Forms and more