Public Member Functions | Properties
Table Class Reference

The table object is used to store information from the dbf file associated with a shapefile. More...

List of all members.

Public Member Functions

bool Calculate (string Expression, int RowIndex, out object Result, out string ErrorString)
 Calculates the the expression taking the values from the specified row of the atrribute table.
bool Close ()
 Closes the attribute table.
bool CreateNew (string dbfFilename)
 Creates a new attribute table.
int EditAddField (string Name, FieldType Type, int Precision, int Width)
 Adds a field to the table. The table must be in editing mode.
bool EditCellValue (int FieldIndex, int RowIndex, object newVal)
 Sets the value of the cell.
bool EditClear ()
 Deletes all rows and fields from the table. Note: The table must be set to allow editing before the rows and fields can be deleted from the table.
bool EditDeleteField (int FieldIndex, ICallback cBack)
 Deletes a field from the table.
bool EditDeleteRow (int RowIndex)
 Deletes a row from the table.
bool EditInsertField (Field Field, ref int FieldIndex, ICallback cBack)
 Inserts a new field into the table.
bool EditInsertRow (ref int RowIndex)
 Inserts a new row into the table.
bool EditReplaceField (int FieldIndex, Field NewField, ICallback cBack)
 Replaces the specified field in the table with the new field.
object get_CellValue (int FieldIndex, int RowIndex)
 Gets the value of the specified cell in the table.
string get_ErrorMsg (int ErrorCode)
 Retrieves the error message associated with the specified error code.
Field get_Field (int FieldIndex)
 Gets the field object at the specified field index in the table.
int get_FieldIndexByName (string Fieldname)
 Seeks field with specified name. Comparison is case insensitive.
object get_MaxValue (int FieldIndex)
 Returns the maximum value for the specified field of the table.
double get_MeanValue (int FieldIndex)
 Calculates the mean value for the specified field of the table.
object get_MinValue (int FieldIndex)
 Returns the minimum value for the specified field.
double get_StandardDeviation (int FieldIndex)
 Calculates the standard deviation for the set of values in specified field.
bool Open (string dbfFilename, ICallback cBack)
 Opens a .dbf table from file.
bool ParseExpression (string Expression, ref string ErrorString)
 Checks if the expression is a valid one.
bool Query (string Expression, ref object Result, ref string ErrorString)
 Selects the rows in the table which agree with the specified expression.
bool Save (ICallback cBack)
 Saves in-memory version of the table to the source file.
bool SaveAs (string dbfFilename, ICallback cBack)
 Saves the table using the specified filename.
bool StartEditingTable (ICallback cBack)
 Sets the table to allow table editing.
bool StopEditingTable (bool ApplyChanges, ICallback cBack)
 Sets the table to prevent editing.
bool TestExpression (string Expression, tkValueType ReturnType, ref string ErrorString)
 Tests the validity of expression and determines its return type.

Properties

string CdlgFilter [get]
 Returns the common dialog filter containing all supported file extensions in string format.
bool EditingTable [get]
 Gets whether or not the table is in editing mode.
ICallback GlobalCallback [get, set]
 The global callback is the interface used by MapWinGIS to pass progress and error events to interested applications.
string Key [get, set]
 The key may be used by the programmer to store any string data associated with the object.
int LastErrorCode [get]
 Retrieves the last error generated in the object.
int NumFields [get]
 Gets the number of fields in the table.
int NumRows [get]
 Gets the number of rows in the table.

Detailed Description

The table object is used to store information from the dbf file associated with a shapefile.

dot_inline_dotgraph_52.png

Graph description

The following code will add the field in the table:

 Shapefile sf = some_shapefile;
 if (sf.EditingTable)
 {
     // string field
     Field fld = new Field();
     fld.Name = "New field";
     fld.Type = FieldType.STRING_FIELD;
     fld.Width = 15;      // 15 characters

     // let's insert it
     int fieldIndex = sf.NumFields;      // it will be inserted as the last one
     sf.EditInsertField(fld, ref fieldIndex, null);
 }

To find the index of field with the given name in the table:

 Shapefile sf = some_shapefile;
    
 // fast call
 int fieldIndex = sf.Table.get_FieldIndexByName("New field");

 // to do the same "manually"
 fieldIndex = -1;
 for (int i = 0; i < sf.NumFields; i++)
 {
     if (sf.get_Field(i).Name == "New field") {
         fieldIndex = i;
         break;
     }
 }

 Debug.Print("Field index: " + fieldIndex.ToString());

Member Function Documentation

bool Table.Calculate ( string  Expression,
int  RowIndex,
out object  Result,
out string  ErrorString 
)

Calculates the the expression taking the values from the specified row of the atrribute table.

Parameters:
ExpressionThe expression to analyze.
RowIndexThe index of the row.
ResultThe result of calculation as variant data type, either boolean, double or string.
ErrorStringAn output string with the description of error in case method failed.
Returns:
True on successful calculation and false otherwise.
New API 4.8:
Added in version 4.8
bool Table.Close ( )

Closes the attribute table.

Returns:
The value can be ignored.
bool Table.CreateNew ( string  dbfFilename)

Creates a new attribute table.

A new table is automatically in editing mode after it is created.

Parameters:
dbfFilenameThe filename for the new table.
Returns:
A boolean value representing the success or failure of creating the new table.
int Table.EditAddField ( string  Name,
FieldType  Type,
int  Precision,
int  Width 
)

Adds a field to the table. The table must be in editing mode.

Parameters:
NameThe name of field.
TypeThe type of field.
PrecisionThe precision of field.
WidthThe width of field.
Returns:
The index of the new field or -1 on failure.
bool Table.EditCellValue ( int  FieldIndex,
int  RowIndex,
object  newVal 
)

Sets the value of the cell.

The table must be set to allow editing before a cell's value may be edited.

Parameters:
FieldIndexThe field index of the cell to be edited.
RowIndexThe row index of the cell to be edited.
newValThe new value to be used to set the specified cell's value.
Returns:
A boolean value representing the success or failure of setting the value of the specified cell in the table.
bool Table.EditClear ( )

Deletes all rows and fields from the table. Note: The table must be set to allow editing before the rows and fields can be deleted from the table.

Returns:
A boolean value representing the success or failure of deleting all rows and fields from the table.
bool Table.EditDeleteField ( int  FieldIndex,
ICallback  cBack 
)

Deletes a field from the table.

The table must be set to allow editing before a field can be deleted from the table.

Parameters:
FieldIndexThe index of the field to be deleted from the table.
cBackThe ICallback object which will receive progress and error messages while the field is being deleted from the table.
Returns:
bool Table.EditDeleteRow ( int  RowIndex)

Deletes a row from the table.

The table must be set to allow editing before a row can be deleted from the table.

Parameters:
RowIndexThe index of the row to be deleted from the table.
Returns:
A boolean value representing the success or failure of deleting the specified row from the table.
bool Table.EditInsertField ( Field  Field,
ref int  FieldIndex,
ICallback  cBack 
)

Inserts a new field into the table.

The table must be set to allow editing before a field can be inserted into the table.

Parameters:
FieldThe new field to be inserted into the table.
FieldIndexThe desired index to be used for the new field being inserted into the table. If the desired index is invalid or unavailable, the actual index used for the new field will be returned.
cBackThe ICallback object which will receive progress and error messages while the new field is being inserted into the table.
Returns:
A boolean value representing the success or failure of inserting the new field into the table.
bool Table.EditInsertRow ( ref int  RowIndex)

Inserts a new row into the table.

The table must be set to allow editing before a row can be inserted into the table.

Parameters:
RowIndexThe desired index to use when inserting the new row into the table. If the desired index is invalid or unavailable, the actual index used to insert the new row will be returned.
Returns:
A boolean value representing the success or failure of inserting the new row into the table.
bool Table.EditReplaceField ( int  FieldIndex,
Field  NewField,
ICallback  cBack 
)

Replaces the specified field in the table with the new field.

The table must be set to allow editing before a field can be replaced in the table.

Parameters:
FieldIndexThe index of the field to be replaced.
NewFieldThe field to be used to replace the specified field in the table.
cBackThe ICallback object which will receive progress and error messages while the specified field is being replced by the new field.
Returns:
A boolean value representing the success or failure of replacing the specified field.
object Table.get_CellValue ( int  FieldIndex,
int  RowIndex 
)

Gets the value of the specified cell in the table.

Parameters:
FieldIndexThe field index of the cell for which the value is required.
RowIndexThe row index of the cell for which the value is required.
Returns:
The value of the specified cell in the table.
Examples:
PointIcons.cs, and ZoomToValues.cs.
string Table.get_ErrorMsg ( int  ErrorCode)

Retrieves the error message associated with the specified error code.

Parameters:
ErrorCodeThe error code for which the error message is required.
Returns:
The error message description for the specified error code.
Examples:
EditAttributes.cs, SelectBox.cs, and ToolTip.cs.
Field Table.get_Field ( int  FieldIndex)

Gets the field object at the specified field index in the table.

Parameters:
FieldIndexThe index of the field in the table to be returned.
Returns:
The field object specified by the field index.
Examples:
ShowAttributes.cs.
int Table.get_FieldIndexByName ( string  Fieldname)

Seeks field with specified name. Comparison is case insensitive.

Parameters:
FieldnameThe name of field to search.
Returns:
The index of field if it exists and -1 otherwise.
Examples:
AddCategoryRange.cs, CalculateArea.cs, EditAttributes.cs, PointIcons.cs, SplitByAttribute.cs, and ZoomToValues.cs.
object Table.get_MaxValue ( int  FieldIndex)

Returns the maximum value for the specified field of the table.

NULL will be returned in case of invalid index.

Parameters:
FieldIndexThe index of the field.
Returns:
The maximum value, either integer, double or string data type.
New API 4.8:
Added in version 4.8
Examples:
AddCategoryRange.cs.
double Table.get_MeanValue ( int  FieldIndex)

Calculates the mean value for the specified field of the table.

NULL will be returned in case of invalid index.

Parameters:
FieldIndexThe index of the field.
Returns:
The mean value, either integer, double or string data type.
New API 4.8:
Added in version 4.8
Examples:
AddCategoryRange.cs.
object Table.get_MinValue ( int  FieldIndex)

Returns the minimum value for the specified field.

NULL will be returned in case of invalid index.

Parameters:
FieldIndexThe index of the field.
Returns:
The minimum value, either integer, double or string data type.
New API 4.8:
Added in version 4.8
Examples:
AddCategoryRange.cs.
double Table.get_StandardDeviation ( int  FieldIndex)

Calculates the standard deviation for the set of values in specified field.

NULL will be returned in case of invalid index.

Parameters:
FieldIndexThe index of the field.
Returns:
The minimum value, either integer, double or string data type.
New API 4.8:
Added in version 4.8
Examples:
AddCategoryRange.cs.
bool Table.Open ( string  dbfFilename,
ICallback  cBack 
)

Opens a .dbf table from file.

Parameters:
dbfFilenameThe filename of the table to be opened.
cBackThe ICallback object which will receive progress and error messages while the table is being opened.
Returns:
The boolean value representing success or failure of the opening table.
bool Table.ParseExpression ( string  Expression,
ref string  ErrorString 
)

Checks if the expression is a valid one.

Parameters:
ExpressionThe expression to analyze.
ErrorStringAn output string with the description of error in case expression is not valid.
Returns:
True if expression is valid and false otherwise.
New API 4.8:
Added in version 4.8
bool Table.Query ( string  Expression,
ref object  Result,
ref string  ErrorString 
)

Selects the rows in the table which agree with the specified expression.

Parameters:
ExpressionThe query expression.
ResultAn array of integer type with the indices of rows which were selected.
ErrorStringAn output string with the description of error on failure.
Returns:
True in case at least one row was selected and false otherwise.
New API 4.8:
Added in version 4.8
Examples:
SelectByQuery.cs.
bool Table.Save ( ICallback  cBack)

Saves in-memory version of the table to the source file.

This method should be called while the table is in editing mode. The editing mode will not be closed.

Parameters:
cBackA callback object to report information about progress and errors.
Returns:
True on success and false otherwise.
New API 4.8:
Added in version 4.8
bool Table.SaveAs ( string  dbfFilename,
ICallback  cBack 
)

Saves the table using the specified filename.

Parameters:
dbfFilenameThe filename to be used to save the table.
cBackThe ICallback object which will receive progress and error messages while the table is being saved.
Returns:
A boolean value representing the success or failure of saving the table.

Sets the table to allow table editing.

Parameters:
cBackOptional. The ICallback object which will receive progress and error events while the table is being set to allow editing.
Returns:
A boolean value representing the success or failure of setting the table to allow editing.
Examples:
EditAttributes.cs.
bool Table.StopEditingTable ( bool  ApplyChanges,
ICallback  cBack 
)

Sets the table to prevent editing.

Parameters:
ApplyChangesOptional. A boolean value representing whether or not to save changes to the table. The default is True, to save the changes.
cBackOptional. The ICallback object which will receive progress and error messages while the table is being set to prevent editing.
Returns:
A boolean value representing the success or failure of setting the table to prevent editing.
bool Table.TestExpression ( string  Expression,
tkValueType  ReturnType,
ref string  ErrorString 
)

Tests the validity of expression and determines its return type.

Parameters:
ExpressionThe expression to test.
ReturnTypeAn output value with the return type, either double, string or boolean.
ErrorStringAn output string with the description of error.
Returns:
True if the expression is valid and false otherwise.
New API 4.8:
Added in version 4.8

Property Documentation

string Table.CdlgFilter [get]

Returns the common dialog filter containing all supported file extensions in string format.

bool Table.EditingTable [get]

Gets whether or not the table is in editing mode.

The global callback is the interface used by MapWinGIS to pass progress and error events to interested applications.

string Table.Key [get, set]

The key may be used by the programmer to store any string data associated with the object.

Retrieves the last error generated in the object.

int Table.NumFields [get]

Gets the number of fields in the table.

int Table.NumRows [get]

Gets the number of rows in the table.

Examples:
PointIcons.cs.
 All Classes Files Functions Enumerations Properties