GrapeCity.Win.MultiRow Namespace > GcMultiRow Class > GetValue Method : GetValue(Int32,String) Method |
Public Overloads Function GetValue( _ ByVal rowIndex As Integer, _ ByVal cellName As String _ ) As Object
Dim instance As GcMultiRow Dim rowIndex As Integer Dim cellName As String Dim value As Object value = instance.GetValue(rowIndex, cellName)
Exception | Description |
---|---|
System.ArgumentNullException | The cellName is a null reference (Nothing in Visual Basic) or string.Empty. |
System.ArgumentException | The cellName does not match the name of any Cells in the Row. |
System.ArgumentOutOfRangeException | The rowIndex is less than 0 or greater than the number of Rows minus 1. |
This method returns the Value of the specified cell without instantiating the cell.
Information about instantiating the cell and row:
By default, all the Cells and Rows in a GcMultiRow control do not have memory, and their process logic and drawing are done by a row and cell template. So, most of the virtual methods exposed in the row and cell need a SectionIndex parameter, so that they can deal with the corresponding operation logic correctly.
The relevant Row and Cell objects need to be instantiated after certain operations, in order to save a specific cell's data, . The CellStyle.BackColor is different from the template and the LinkLabelCell's LinkLabelCell.LinkVisited property. Instantiating a row or cell, requires more memory. The system performance may be effected, so you should avoid using the instantiated methods and properties if possible.
The following methods, properties, or actions will BRING about the instantiation of the Row object |
---|
accessing the current row with the CurrentRow property |
accessing the specific row with the RowCollection.Item property |
copying the row collection with the RowCollection.CopyTo method |
accessing a row collection member with an enumerator (foreach) |
when a user adds a new row with the detached row |
when a user presses Ctrl+Del to delete one or more rows |
hiding one or more rows with the filter function |
the parent row is instantiated when a cell is instantiated |
The following methods, properties, or actions will BRING about the instantiation of the Cell object |
---|
accessing the current cell with the CurrentCell property |
accessing the specific cell with the Item(Int32,Int32) or Item(Int32,String) property |
clicking a LinkLabelCell whose LinkLabelCell.TrackVisitedState property is true |
The following methods will NOT BRING about the instantiation of the Cell or Row object |
---|
getting or setting the Value by invoking the GetValue(Int32,Int32) or SetValue(Int32,Int32,Object) method |
getting the FormattedValue by invoking the GetFormattedValue(Int32,Int32) method |
getting the Cell.EditedFormattedValue by invoking the GetEditedFormattedValue(Int32,Int32) method |
accessing the CurrentCellPosition property, but not the CurrentCell or CurrentRow property |
modifying the data with the DataSource property |
Note: The above list may not contain all the methods involved with the instantiation action of the row and cell. For more details, refer to the method and property descriptions.
private void Form1_Load(object sender, EventArgs e) { GrapeCity.Win.MultiRow.TextBoxCell text1 = new GrapeCity.Win.MultiRow.TextBoxCell(); GrapeCity.Win.MultiRow.TextBoxCell text2 = new GrapeCity.Win.MultiRow.TextBoxCell(); text1.Name = "text1"; text2.Name = "text2"; text2.Style.Format = "c"; GrapeCity.Win.MultiRow.Template template1 = GrapeCity.Win.MultiRow.Template.CreateGridTemplate(new GrapeCity.Win.MultiRow.Cell[] { text1, text2 }, 160, GrapeCity.Win.MultiRow.AutoGenerateGridTemplateStyles.ColumnHeader | GrapeCity.Win.MultiRow.AutoGenerateGridTemplateStyles.RowHeaderAutoNumber); template1.ColumnHeaders[0].Cells[0].Value = "Column1"; template1.ColumnHeaders[0].Cells[1].Value = "Column2"; gcMultiRow1.Template = template1; gcMultiRow1.RowCount = 3; gcMultiRow1[1, 1].Value = 5; } private void button1_Click(object sender, EventArgs e) { listBox1.Items.Add(gcMultiRow1.GetValue(1,1).ToString()); listBox1.Items.Add(gcMultiRow1.GetValue(1,"text2").ToString()); }
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim text1 As New GrapeCity.Win.MultiRow.TextBoxCell() Dim text2 As New GrapeCity.Win.MultiRow.TextBoxCell() text1.Name = "text1" text2.Name = "text2" text2.Style.Format = "c" Dim template1 As GrapeCity.Win.MultiRow.Template = GrapeCity.Win.MultiRow.Template.CreateGridTemplate(New GrapeCity.Win.MultiRow.Cell() {text1, text2}, 160, GrapeCity.Win.MultiRow.AutoGenerateGridTemplateStyles.ColumnHeader Or GrapeCity.Win.MultiRow.AutoGenerateGridTemplateStyles.RowHeaderAutoNumber) template1.ColumnHeaders(0).Cells(0).Value = "Column1" template1.ColumnHeaders(0).Cells(1).Value = "Column2" GcMultiRow1.Template = template1 GcMultiRow1.RowCount = 3 GcMultiRow1(1, 1).Value = 5 End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ListBox1.Items.Add(GcMultiRow1.GetValue(1,1).ToString()) ListBox1.Items.Add(GcMultiRow1.GetValue(1,"text2").ToString()) End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2