winforms-interop

WinForms TreeView: check if Checkbox is hidden

假装没事ソ 提交于 2019-12-11 19:53:00
问题 I am using the following solution to show or hide checkboxes in a TreeView: https://stackoverflow.com/a/22230299/1583649 However, now i would like to know how to check if the checkbox is hidden or not for the node. For example, i want to be able to set checkbox.checked to true (or false) on only the children of a top-level node that have a checkbox visible when the top-level node is checked. Is there a way to do this? 回答1: TVM_GETITEM or TVM_GETITEMSTATE can be used to get the state, which

Reading data from an Excel Spreadsheet [duplicate]

我只是一个虾纸丫 提交于 2019-12-11 18:29:46
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Read data from Excel files I'm having some trouble reading from an Excel spreadsheet in C#. I have this code which I read every cell from A to X. int i = 1; int number; System.Array myvalues; string[] strArray; Microsoft.Office.Interop.Excel.Range range = worksheet.get_Range("A" + i.ToString(), "X" + i.ToString()); while(range.Count!=0) { i++; range = worksheet.get_Range("A" + i.ToString(), "X" + i.ToString());

ElementHost flickers black borders on resize

荒凉一梦 提交于 2019-12-11 07:28:42
问题 Disclaimer : This is not a duplicated post. I googled about the issue. Also read this, this and this SO questions. I tried some of those things but nothing seemed to help. Consider the following simple example code. It's just an empty ElementHost inside a WinForm (no WPF control inside): using System.Windows.Forms; using System.Windows.Forms.Integration; namespace WindowsFormsApplication15 { public partial class Form1 : Form { public Form1() { InitializeComponent(); ElementHost host = new

WPF controls in Winforms do not update access keys/mnemonic underlines

一世执手 提交于 2019-12-11 03:55:28
问题 I have a Winform with a menu strip that hosts a WPF control that has some buttons. The toolStripMenuItems and the WPF buttons all have access keys set up. When I hit "Alt", the letters for all the access keys become underlined as expected. When I hit the "Alt" key a second time the lines disappear on the toolstripMenuItems but not on the WPF buttons. The access keys still work. It appears that the UI is not keeping up with the keystrokes. Is this by design? And how do I get uniform behavior

WPF: When is a TabItem actually loaded, rendered and completly ready?

筅森魡賤 提交于 2019-12-11 03:33:30
问题 In my WPF application, I have a class that serves as a wrapper around QuickTime. It provides all the specific or simplified functionality I need. To function, it needs to create an instance of QuickTime's ActiveX control and place it in a valid Windows Forms window. My app being WPF, the constructor works like this: public VideoPlayerQT(WindowsFormsHost wfHost) { AxQTControl qtControl = new AxQTControl(); wfHost.Child = qtControl; } Now in the main window, I use the player like this: private

WPF User Control in WinFORMS: Project Structuring

南笙酒味 提交于 2019-12-11 00:19:44
问题 SCENARIO I decided to work on WPF technology for my new application. This application has to be called on Menu click from a WinForms window. So I created a WPF UserControl Library and integrate it to display in parent WinForms Form using Element Host. My Application It contains 3 child usercontrols which are encapsulated inside another usercontrol with tabContent Control. I prefered this approach as firing events from Child UserControl and handling in WinForms (subscribing events) seemed

using the same icon for the .exe and a form in a Windows Forms application without duplicating it?

爷,独闯天下 提交于 2019-12-10 18:43:33
问题 I have an icon for my application, and I want to use it as both the EXE icon and the icon on the main form. When I say "EXE icon" I mean the icon that is embedded by the /win32icon option to the C# compiler or the icon specified in the Application section of the project settings in Visual Studio. This is the icon displayed by Windows Explorer. However, the application form uses a default icon, which is what shows up in the title bar and when you press Alt-Tab. I want to use the same icon for

Creating a form from a WinForms Control hosted within WPF — Owner is not set

折月煮酒 提交于 2019-12-10 14:22:36
问题 Scenario I have the following scenario (I've stripped it down to a sample application): A WPF application with a window ( MainWindow ) hosting a WinForms UserControl ( UserControl1 ). The control is added dynamically in the code behind to a WindowsFormsHost UserControl1 has a button which opens a form ( Form1 ) It uses form1.Show(this) . Problem is: Form1 's .Owner property is null. In the real application, some work is done involving the .Owner property which means I can't just ignore this

Custom window frame with DWM: how to handle WM_NCCALCSIZE correctly

断了今生、忘了曾经 提交于 2019-12-07 05:54:09
问题 I'm trying to make a custom window frame for my form using DWM. The platform is C# WinForms, Pinvoking DWM. Following the MSDN article on making custom window frame with DWM, the main steps are next: Remove standard frame (non-client area), returning 0 in answer to WM_NCCALCSIZE message Extend the frame into client area using DwmExtendFrameIntoClientArea function I handle WM_NCCALCSIZE message in the next way: protected override void WndProc(ref Message m) { switch (m.Msg) { case WM

How to connect to outlook 2010 while its running in c#?

无人久伴 提交于 2019-12-06 19:05:02
问题 What I am trying to do is add an "Email To..." button to a winform client that opens a new outlook mail window and attaches a file so the user can forward it. I can get the outlook integration working just fine if outlook is not already running. This is a C# .NET 4.0 winforms app, using the Outlook 14.0 interop library, against Outlook 2010 32 bit running on windows 7 64 bit machine. I have the app already compiled to x86 for other reasons so I doubt its a 32/64 bit issue. Here is my code: //