Jump to content
Xtreme .Net Talk

ThienZ

Avatar/Signature
  • Posts

    45
  • Joined

  • Last visited

Everything posted by ThienZ

  1. if i have a class that has attributes: attr01, attr02, ... attr16, and i want to check a same thing for each of these attributes it would be convenient if i can evaluate his string : for(int i=1; i<=16; i++) { if(eval["myClass.attr" + i] ..... } i know System.Controls("...") from VBA hat evaluate strings to commands. Are there something like this in C# too? thx in advance.
  2. i checked this sql code with swl enterprise manager and it says "Syntax check successful!". But if i run my code it says unhandled exception, system error on the executenonquery line... string createtbl = "CREATE TABLE typicals (typical varchar(200),typicalnr int);"; SqlCommand myinsertcommand = new SqlCommand(createtbl, mycon); myinsertcommand.ExecuteNonQuery(); actually i want to use "create table if not exists", but if i check the syntax from this command it won't accept the "if not exists" part... can someone help me? thx in advance.
  3. thx Winston :) ah... i meant VBA, in VBA i used to use .BeginGroup for the line :)
  4. i took a peek to w3school's xsl tutorial site, and i wonder if it would be easier if i filter the rows in xsl because i have 167 columns in this dataset i'm working on. and it seems that xsl is more likely for web purposes? i'm using dataset to work on excel sheets...
  5. i fill a strongly typed dataset from excel, and then i write the sourcefilename, source sheet, and rownr into the columns filename, sheetname and rownr in the dataset. however excel takes takes the empty rows too into the dataset. like if the sheet has 100 active rows, but actually only the first 10 rows has values, the oledbdatadapter fill the dataset with these 100 rows and all the "cells" in the dataset in row 11-100 has (Null). i have some ideas : - before i write the filename, sheet, and rownr, i filter all the empty rows manually. i go through all rows and for each row i check the cell. if they are empty i delete them. but then i don't know anymore which row which rownr has (because there would be an empty row in the middle too) - after i write the filename, sheetname and rownr i go through all rows and for each row i transpose it, put it in a new dataset, sort it, and see if the 4th row has a value. if no then i can delete this row. does anyone has a better idea? (i'm sure there are many better ways.....)
  6. right now i'm using a dumb method that deletes the extra columns, but i'm sure that there are better ways public static void adjustDataTable(DataTable sampleDT, DataTable toadjustDT) { DataTable extracols = toadjustDT.Clone(); foreach(DataColumn col in sampleDT.Columns) extracols.Columns.Remove(col.ColumnName); foreach(DataColumn col in extracols.Columns) toadjustDT.Columns.Remove(col.ColumnName); }
  7. i want to fill data to a strongly typed dataset fom excel. if i fill this strongly typed dataset with a sheet which has more columns than the typed dataset, these extra columns are put on the end of the typed dataset. example : my strongly typed dataset has 3 columns : name, address, id the excel sheet has 5 columns : name, birthdate, phone, id, email if i do this : OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data Source=" + filename + ";Extended Properties=Excel 8.0;"); conn.Open(); OleDbCommand cmd = new OleDbCommand("SELECT * FROM [sheet1$]", conn); OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.SelectCommand = cmd; myDataSet mynewds = new myDataSet(); adapter.Fill(mynewds, "mytable"); conn.Close(); mynewds has these columns : nam, address, id, birthdate, phone, email. how can i fill my strongly typed dataset only with columns, which in my strongly typed dataset exist? thx
  8. thx PlausiblyDamp! is it possible to change it from .NET?
  9. how can i always show the shotcut in contextmenu? Sometimes you can see the underlines, sometimes not....
  10. i want to insert a line in a menu context. how can i do this? in VB it was the .BeginGroup attribute. a cut from my code how i insert the menuitem : contextMenutreeview.MenuItems.Add("Alle Unterbilder selektieren", new System.EventHandler(this.SelectAllChildren)); Thx in advance :)
  11. and how can i do that? i tried to write like this: public class DataSetExt : DataSet { private int pos_objadr1; public DataTable OL { get { return this.Tables["OL"]; } public objadr1 { return this.Tables["OL"].Columns[pos_objadr1]; } } } with this i can write "myDataSetExt.OL" to get the table "OL", right? but what should i do so i can write "myDataSetExt.OL(1).objadr1" to get line 1 column pos_objadr1 from table OL? i tried to make objadr1 inside OL like up there, but it doesn't work.... Thx.
  12. i'm trying to get a "typisierte" DataSet like this: (from MSDN) // This accesses the CustomerID column in the first row of // the Customers table. string s; s = dsCustomersOrders1.Customers[0].CustomerID; what do you call for "typisiert"? (My MSDN is in german, so i don't know the english word) i tried to look in MSDN but didn't find an example code for making "typisierte" DataSet. Should i extend the DataSet like this? public class DataSetExt : DataSet { //... with all set and get for each specific tables and column names } or how should i do it? thx in advance. :)
  13. No, Alex, FullRowSelect is already FALSE by default and i didn't changed it....
  14. no problem Alex :) i don't know about Option Strict, maybe it's an Option in VB? I guess this option is set to TRUE by default in C#...
  15. thx Alex, i tried to write like you did, but it didn't work... after some tries this code worked : private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if((Keys) e.KeyValue == Keys.Escape) this.Close(); } Should i cast the int into Keys or are there better ways? Because .net can't compare int and keys... thx :) ps: how do make a quote with "C# Code"? i tried [C# Code][/[C# Code]] but it won't do :p
  16. wow.. thx AlexCode... that's even better! Usually i make an extra button and set the width to 0 :lol: Am i writing this right? cause this isn't working ^^;;; (I'm new to C# so i still need to get used to it...) private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(e.Equals(Keys.Escape)) this.Close(); }
  17. How can i create a button with a standard windows icon on it? (a.e. Open icon) Now i take a screen capture from office, edit it in paintbrush, and then add the image on the button.... But i'm sure that there would be better ways... :p Thx :)
  18. i read mike's post before that pointed a tutorial for excel automation... but i didn't found how can i open a file (a.e. csv file) with semicolon as delimiter... Can someone help me writing the code in C#? Thx in advance. :)
  19. Is there any better way to close a form with escape key than making a button "Close", setting it as CancelButton, and then write inside a code to close like this : private void buttonClose_Click(object sender, System.EventArgs e) { this.Close(); }? thx in advance :)
  20. i made a treeview and want to check or uncheck the node if mouse is clicked over it. my code looks like this : private void treeViewBildObjekt_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { TreeNodeExt selectedNode = (TreeNodeExt) treeViewBildObjekt.GetNodeAt( treeViewBildObjekt.PointToClient(Cursor.Position)); if ((selectedNode != null) && (e.Button == MouseButtons.Left)) { selectedNode.Checked = !selectedNode.Checked; } } but if i click on the same height as the node, not on the text, the node would be checked or unchecked too... this would be inconvenient for the users, because the width of the treeview is big, so if the user click on the empty space on the right or left side of the tree, the node on the same height is going to be checked or unchecked.. how can i make so this would only happen if i click on the text? thx in advance :) ps: i'm using C# if it makes any differences
×
×
  • Create New...