ThienZ
Avatar/Signature-
Posts
45 -
Joined
-
Last visited
About ThienZ
- Birthday 06/14/1981
Personal Information
-
Visual Studio .NET Version
.NET 2003
-
.NET Preferred Language
C#, VBA
ThienZ's Achievements
Newbie (1/14)
0
Reputation
-
Hi, does anyone know how to make a chm file from a word document? It should be semi automatic, because the word file is still changing... I want to connect this chm file with HelpProvider later. thx in advance
-
Hi, how can I read an open Excelsheet into a dataset? Usually I'm using this : String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data Source=c:\xlfile.xls;Extended Properties=Excel 8.0;"; OleDbConnection objConn = new OleDbConnection(sConnectionString); objConn.Open(); OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM [sheet1$]", objConn); OleDbDataAdapter myda = new OleDbDataAdapter(); myda.SelectCommand = objCmdSelect; myda.Fill(ds); I can't use this way because i can't close the file... Thx
-
Hi, i have a panel with AutoScroll set to true. Can i set SmallScroll (this property was in VBA)?
-
Hi, i'm trying to make an addin from c#.net. The project was created from Extensibility Projects - VS.Net Add-in, and then i added a reference to MS Excel 11.0 Object Library. The Problem is that if i'm using _CommandBarButtonEvents_ClickEventHandler, CommandBar, CommandBars, CommandBarButton, CommandBarPopup, MsoButtonStyle, the compiler makes these warnings : E:\VS Projects\FDB2XLaddin\Menu.cs(271): 'Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler' is defined in multiple places; using definition from 'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\office.dll' i attached a screenshot too if you want to see it.... What should I do to correct this?
-
Excel with c#.net: loop through range?
ThienZ replied to ThienZ's topic in Interoperation / Office Integration
i've just read the other thread about "why is it running so slow", and.... should i do this : for(int a=1; a<=xlRng.Areas.Count; a++) { Excel.Range area = xlRng.Areas[a]; for(int r = 1; r<=area.Rows.Count; r++) { for(int c = 1; c<=area.Columns.Count; c++) { datarow = dtBNr.NewRow(); datarow[Constants.strcolNr] = ((Excel.Range) area[r,c]).Value2; dtBNr.Rows.Add(datarow); } } } or better like this : for(int a=1; a<=xlRng.Areas.Count; a++) { Excel.Range area = xlRng.Areas[a]; string [,] str = new string[area.Rows.Count,area.Columns.Count]; str = area.??? //somehow copy the range into a 2d-array for(int r = 0; r<area.Rows.Count; r++) { for(int c = 0; c<area.Columns.Count; c++) { datarow = dtBNr.NewRow(); datarow[Constants.strcolNr] = str[r,c]; dtBNr.Rows.Add(datarow); } } } or do both need the same time to process the code? thx in advance :) -
Hi, is it possible to remove or turn an event off (and then on) from a control? I add an event like this : this.KeyPress += new KeyPressEventHandler(TextBoxMaxNr_KeyPress); How can i turn it on/off ? Thx in advance
-
thx guys :) now the code looks like this : private void TextBoxNumberOnly_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(!Char.IsNumber(e.KeyChar) && !( ((int) System.Text.Encoding.ASCII.GetBytes(e.KeyChar.ToString())[0]) == 8)) { e.Handled = true; } } the only problem is that this code is a little slow in the first usage of escape key (it thinks about a second), but after that you notice nothing else... maybe any other suggestions to better the running time of the code?
-
i tried this : oTB.KeyPress += new KeyPressEventHandler(TextBoxNumberOnly_KeyPress); private void TextBoxNumberOnly_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(!Char.IsNumber(e.KeyChar)) { e.Handled = true; } } but this way i can't press backspace too.... the cursor arrow and delete buttons work tho... how should i do this a better way? thx in advanced... :)
-
Excel with c#.net: loop through range?
ThienZ replied to ThienZ's topic in Interoperation / Office Integration
wow.. thx mike... and thx too that you reminded me that the range can be multi area range too... :) -
Excel with c#.net: loop through range?
ThienZ replied to ThienZ's topic in Interoperation / Office Integration
actually i tried this before : foreach(Excel.Range cell in S.Cells) but this didn't work, it said : An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll Additional information: Member not found. i tried to look for the members of S (Selection) but didn't fond any that would fit.... Can anyone help me plz? Thx in advance. -
if i have a range : Excel.Range S = (Excel.Range) oApp.Selection; which has one columns and more than rows, how can i loop through each cell? In VBA it was just like this : For Each mycell In S '... Next mycell Thx
-
if i make a label and set the font into bold, strangely the last letters in the label shrink.... if i make the text longer, only the last letters shrink, the one in the middle not anymore.... see pictures : labelshrink.jpg for .net to compare labelshrink2.jpg in VBA (Excel) any idea...?
-
I want to create an addin that loads automatically in Excel if Excel starts up. First this addin should make a menu, this menu has three modes: local, client and server. The menu has local mode as default. private enum eMenuModus {LokalModus, ClientModus, ServerModus}; public void OnStartupComplete(ref System.Array custom) { createmenu(eMenuModus.LokalModus); } part of sub createmenu : //.... if(oMenuModus == eMenuModus.LokalModus) { MyButton = (ofcore.CommandBarButton) commandBarPopup.Controls.Add(1, omissing , omissing , omissing , omissing); MyButton.Caption = "&Globale Aktualisierung"; MyButton.Tag = MyButton.Caption; MyButton.Style = ofcore.MsoButtonStyle.msoButtonIconAndCaption; MyButton.FaceId = 349; MyButton.BeginGroup = true; MyButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.MyButton_Click); } //.... ofcore.CommandBarPopup commandBarPopup1 = (ofcore.CommandBarPopup) commandBarPopup.Controls.Add( ofcore.MsoControlType.msoControlPopup, 1, "", omissing, true); commandBarPopup1.Caption = "&Modus"; commandBarPopup1.BeginGroup = true; MyButton = (ofcore.CommandBarButton) commandBarPopup1.Controls.Add(1, omissing , omissing , omissing , omissing); MyButton.Caption = "&Lokal"; MyButton.Tag = MyButton.Caption; MyButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.ButtonChangeModus_Click); MyButton = (ofcore.CommandBarButton) commandBarPopup1.Controls.Add(1, omissing , omissing , omissing , omissing); MyButton.Caption = "&Client"; MyButton.Tag = MyButton.Caption; MyButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.ButtonChangeModus_Click); //... for test i signed the sub ButtonChangeModus_Click for change mode buttons and MyButton_Click for every other button that is clicked ButtonChangeModus_Click and MyButton_Click look like this : private void MyButton_Click(ofcore.CommandBarButton cmdBarbutton,ref bool cancel) { MessageBox.Show(cmdBarbutton.Caption + " was Clicked","MyCOMAddin"); } private void ButtonChangeModus_Click(ofcore.CommandBarButton cmdBarbutton,ref bool cancel) { switch(cmdBarbutton.Caption.Replace("&","")) { case "Lokal": createmenu(eMenuModus.LokalModus); break; case "Client": createmenu(eMenuModus.ClientModus); break; case "Server": createmenu(eMenuModus.ServerModus); break; default: break; } } The problem is : - if after excel loads I click on a random button (except change mode buttons), the messagebox comes out. But after that nothing happen if i click on any button (incl. the change mode buttons) - if i click on the change mode buttons after excel loads, the menu would change into what it suppose to be. But if i change the mode 5 times, and if i click on a button that is on the three modes, then the messagebox appears 5 times too... Can someone please help me how to create the menu in the right way? Thx :)
-
newbie Q: creating a global variable array of strings?
ThienZ replied to ThienZ's topic in Visual C# .NET
thx marble_eater, this works :)