Február 15th, 2012
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
int num;
if ((!Int32.TryParse(e.KeyChar.ToString(), out num)) && !(e.KeyChar == (char)8)) e.Handled = true;
}
Posted in .NET, Ostatné/Other VC#, Visual C# | No Comments »
Február 15th, 2012
private void comboBox1_DropDown(object sender, EventArgs e)
{
comboBox1.Items.Clear();
string baseDir = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
string[] dirPaths = Directory.GetDirectories(baseDir);
foreach(string dir in dirPaths)
{
comboBox1.Items.Add(new DirectoryInfo(dir).Name);
}
}
Posted in .NET, Ostatné/Other VC#, Visual C# | No Comments »
November 11th, 2011
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
...
public string GetCellValue(string filename, int row, int column, int sheet_number)
{
SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(filename, false);
WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart;
Worksheet sheet = workbookPart.WorksheetParts.ElementAtOrDefault(sheet_number).Worksheet;
SharedStringTablePart stringTablePart = workbookPart.SharedStringTablePart;
Cell cell = sheet.Descendants<Row>().ElementAt(row).Descendants<Cell>().ElementAt(column);
string value = cell.CellValue != null ? cell.CellValue.InnerXml : String.Empty;
if (cell.DataType != null && cell.DataType.Value == CellValues.SharedString)
return stringTablePart.SharedStringTable.ChildElements[Int32.Parse(value)].InnerText;
else
return value;
}
Posted in .NET, Ostatné/Other VC#, Visual C# | No Comments »
November 11th, 2011
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
...
public string GetSheetCount(string filename)
{
return SpreadsheetDocument.Open(filename, false).WorkbookPart.WorksheetParts.Count().ToString();
}
Posted in .NET, Ostatné/Other VC#, Visual C# | No Comments »
Október 25th, 2011
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("ALTER TABLE TableName ALTER COLUMN ColumnName AUTOINCREMENT(1,1);"); //(1,1)->The starting value will be 1, and it will increment by 1.
ADOQuery1->ExecSQL();
Posted in Databáza/Database, TurboC++ | No Comments »