|
Thanks. What if I were to want to set the Alignment property of the TabControl itself ? I've gotten continuous errors with this as well.
|
|
|
|
|
Again, a TypeConverter . Use TypeDescriptor.GetConverter(typeof(TabAlignment)) to get an EnumConverter . You might want to read-up on the TypeConverter in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Cool, i'll read up on the type converter, since im guessing if i want to set any properties that are not strings, this is what i will be doing. Thanks for your help.
|
|
|
|
|
Word of warning - not every type has an associated TypeConverter . Only those types that are attributed with or inherit the ConverterAttribute with a valid TypeConverter (or simulate this through the component model) work. Enums, primatives, and many structs support TypeCoverter s. If you need something more encompassing, then forget about using the <appSettings> section and use a serialization approach, like using XML Serialization (see the System.Xml.Serialization namespace in the .NET Framework sDK). There are many articles here on CodeProject that discuss such an alternative. You could even create your own .config section and use XML Serialization to deserialize more complex types that may or may not have a TypeConverter associated with them. Just search this site for examples.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Can you group sections in a config file, such as
<configuration>
<appsettings>
<add key="LabelColor" value="Red">
<add key="LabelText" value="Test text">
|
|
|
|
|
Sorry, forgot to click the Do not treat <'s as HTML tags
<configuration>
<appsettings>
<add key="LabelColor" value="Red">
|
|
|
|
|
Ok, dont I dont get that one I think you know what I mean. Can i group keys via a tag such as "label" for all keys refering to attributes of a label ?
|
|
|
|
|
Ok, dont I dont get that one I think you know what I mean. Can i group keys via a tag such as "label" for all keys refering to attributes of a label ? Because it keeps giving me a problem with it.
|
|
|
|
|
You might want to encode your < and > with < and > next time.
You can group sections, but they must be accessed as part of a group. You really need to read about .config file. See the IConfigurationSectionHandler for good information and a start. Once you decide to group a section you cannot move it around.
For example, the system.web section is a group and there are many section handlers configured under it (configured in the machine.config file). They are all accessed as "system.web\sectionName". If you change the group they are in, you break the code.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I want to display selected items in a listview on another form. for example, I have a form with a listview, three textboxes (lastName, firstName, idNumber), and three buttons (Add, Save, View Form). When I click the view form I want the selected row of items to be displayed on another form that has three textboxes. I have tried many different techniques but none work. Does anyone know how to do this? Any help would be appreciated especially a coded example!!!!
|
|
|
|
|
If these are in the same AppDomain (by default, every process includes one AppDomain), you only need a reference to those TextBox es. It's really a simple object-oriented problem.
So, for one example, when you create your Form with the ListView , pass a reference to the Form with the three TextBox es. Make those TextBox es public or internal (internal is public within an assembly). In the ListView.SelectedIndexChanged , get the ListViewItem and set the TextBox.Text property in the other form using the reference you have to it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear forum members,
An object of a managed class (written in C#) is passed to the
clipboard during drag&drop operation. The object has to be
dropped on to a MFC view (written in VC++ .Net).
How do I create/access my object from the COleDataObject
which I get while 'Droping' into a view ?
Is there any other way to do this ?
Thanks in advance.
svkr.
|
|
|
|
|
I already answered your previous post[^]. Like it or not, those are your only two options: exposing a CCW and publishing the interface, or marshaling the data.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I've been using this code without any problems for ages
FolderBrowserDialog Dialog = new FolderBrowserDialog();
Dialog.RootFolder=Environment.SpecialFolder.Personal;
Dialog.ShowDialog();
This stopped working this afternoon just before a demo of my app; There is just a grey window with the create new folder button and OK. Copied into a new app with a button the code works as i would expect.
The only thing i think might have caused it was that i applied a manifest to get the XP look and feel just before i compiled. I can't get the old style browser back now though, i've deleetd the exe and recompiled etc.
this is the manifest i used with the AppName changed to Appname
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0">
<assemblyidentity
version="1.0.0.0"
="" processorarchitecture="X86" name="Microsoft.Winweb.AppName" type="win32">
<description>.NET control deployment tool
<dependency>
<dependentassembly>
<assemblyidentity
type="win32"
="" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorarchitecture="X86" publickeytoken="6595b64144ccf1df" language="*">
anyone has any ideas, i'd be very happy to hear some answers
Russell
|
|
|
|
|
I once experienced the same thing. After long experiments I discovered that this error occurs when the COM threading model for an application is multithreaded apartment (MTA) instead of single-threaded.
<br />
[System.STAThread]<br />
static void Main()<br />
{ <br />
System.Windows.Forms.Application.Run(new MainForm());<br />
}<br />
Maybe you changed that too?
www.troschuetz.de
|
|
|
|
|
Stefan,
You are a complete and utter hero. I did indeed change the threading model of the application, i had never even thought that that could have caused the problem, i'd got myself convinced that it was something to do with that manifest.
Thanks, at least now i know why it's broke i can test some threories
Russ
PS. i just checked the code, and it was just the [System.STAThread] that was missing, excellent fix, thanks
|
|
|
|
|
My pleasure
arachnoid wrote:
i had never even thought that that could have caused the problem
I know what you mean. I only discovered this solution by accident.
arachnoid wrote:
now i know why it's broke i can test some threories
Maybe you can find out why the COM threading model affects the FolderBrowserDialog this way. I never figured that out
www.troschuetz.de
|
|
|
|
|
i'm going to be coding a prog over the weekend that makes extensive use of threads, so hopefully i'll understand more about them soon. I've only ever used threads in Java and VB(Don't go there, it hurt bad), so i'm just trying to get to grips with syntax etc at the moment.
I don't see why the folderbrowser should be sensitive to the threading model when the commondialog isn't, they do pretty much the same thing after all.
I've just found some code on MS site that shows how to use the clipboard from within an MTA thread by spawning an STA thread within your apartment, maybe that'll work for the folderbrowser.
Russ
|
|
|
|
|
Hi guys, here's my problem.
I have a C# console application and a C# windows forms application running on Windows 2000. The console app runs in a full-screen console, the windows app in a normal window.
Most of the time I will be in full screen mode. But sometimes, my console app will need the help of my windows app, so it makes a remote call to the windows app.
The windows app maximizes iself and takes the focus (user needs to see some information). This causes the console to minimize, and I can see windows desktop, taskbars, all that. After the windows app is done, I want the console app to take the focus back and into fullscreen mode again.
But I can't seem to get that last step to work. Best I've been able to do is make the console window blink on the taskbar. I used DllImport attribute to import user32.dll, and used the WinAPI function SetForegroundWindow to do that.
I basically want to emulate the Alt-Tab functionality. So, since Alt-Tab works there must be a proper way for me to get it to work too. I just don't know what that is. What's the proper way to do this?
|
|
|
|
|
Why is the console app full-screen? This is atypical of a console application. You might consider redesigning your application as a Windows Forms application that can prompt for it's own data. If the console application contains important code you don't want to port, consider using a shared assembly that both the console and Windows Forms application use.
As far as simulating Alt+Tab, you can use SendKeys like so:
SendKeys.Send("%{TAB}"); If you want to do this programmatically, P/Invoke SystemParametersInfo and change the SPI_SETFOREGROUNDLOCKTIMEOUT to 0. See the Platform SDK documentation for the SetForegroundWindow for more information and the reason why.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for your prompt reply!
The console application is full screen because it is being exec'd by a legacy application that must run in a full-screen console window. (This legacy system will be replaced by something being written in .NET from scratch in a year or 2, but until then I'm stuck with this as an interim solution).
I am able to switch tasks with no problems if the windows are not full-screen mode windows. I am only having problems if the console window is in full-screen mode.
I don't really want to simulate Alt-Tab. I only mentioned it because Alt-Tab has no problems switching to a full-screen window, so I know there is a way I can do it too. I just want the console application to give itself focus and maximize itself back to full-screen after the windows application has done its thing.
I will go ahead and read up on that documentation, and see if it solves my problem.
|
|
|
|
|
Is it possible to create an assembly with both C# files and MC++ files?
I have MC++ code that I need it to be private but the code uses it is in C#.
I am open to other suggestions. (ie making the MC++ assembly such that it can only be used by a specific assembly)
Thanks!
Orhun Birsoy
|
|
|
|
|
If you want your MC++ assembly to be used only by another assembly, then use a StrongNameIdentityPermissionAttribute at the assembly level. This also means you should sign your assembly, which is a good idea anyway. To generate a key pair, use:
sn.exe -k KeyFile.snk Use this key pair for all your assemblies or for assemblies for a product. For more information about the benefits of signing an assembly (to give it a strong name), see the .NET Framework SDK documentation.
Then use the file path (relative to the target directory or an absolute path) in the [assembly: AssemblyKeyFileAttribute] for your projects.
Assuming your C# project is called MyCSharpAssembly.dll with version 1.0.0.0 and a public key (you can get this by running sn.exe -Tp MyCSharpAssembly.dll , using the larger number), add an assembly-level attribute to your MC++ assembly like so:
[assembly: StrongNameIdentityPermission(
SecurityAction.RequestMinimum,
Name="MyCSharpAssembly",
Version="1.0.0.0", // Optional
PublicKeyToken="0123456789abcdef...........")] The public key token is very long. You can copy this and concatenate lines yourself. See the documentation for the StrongNameIdentityPermissionAttribute in the .NET Framework SDK for more information and a sample or two.
If MC++ can compile a .NET module (the module contains type metadata and the IL), which I don't remember off hand, you can compile a module and then add it to the C# assembly (along with the module containing the IL from the C# source files) using the csc.exe command-line compilers along with the /addmodule switch.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the info!
I know about signing and security but couldnt find the attribute I am looking for. (StrongNameIdentityPermissionAttribute is exactly what am looking for).
But to iterate the problem, what if I want to use the MC++ assembly (or any other assembly which I want limited use) to be used by some additional assemblies? If I understood your answer I must change(recompile etc) MC++ assembly for each assembly that uses it.
...Reading MSDN....
OK i do not have to provide a Name, but still all the assemblies that uses this limited access assembly had to be signed with the same public-private key, am I correct? Although for my current problem this is perfect, this might not be the case in my future problems .
I will still investigate compiling a mixed language assembly, but I am almost sure that you can not do it with VS IDE.
Orhun Birsoy
|
|
|
|
|
If you want the MC++ assembly to be only used by your assemblies, use the StrongNameIdentityPermissionAttribute but only specify the public key that is paired with a private key you use to sign all your assemblies. This is actually done for several classes throughout the .NET Framework Class Library (.NET FCL) as well.
If you want to use the MC++ assembly with multiple assemblies, then use this approach instead of adding it as a module to other assemblies. It's a waste of size and will be a pain to maintain.
Microsoft MVP, Visual C#
My Articles
|
|
|
|