|
ImageIndex is an int type
[C#]
public int ImageIndex {get; set;}
but in design time , at property grid it showed that was a Image with combobox, why?
if I want add the imageindex property like this in my new control,how to define it?
|
|
|
|
|
lu ming wrote:
if I want add the imageindex property like this in my new control,how to define it?
add the Browsable(true) attribute to the property
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
That just tells the designer that the attribute is browsable, not how to edit the value. That's what a UITypeEditor is for, along with the EditorAttribute .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You should look into the System.ComponentModel namespace, specifically the EditorAttribute and UITypeEditor classes.
There are some already created for you, but you need to follow certain guidelines. For starters, the class in which you would define an ImageIndex property must have a Parent property that references a Control with an ImageList property type (the property name doesn't matter). Then attribute your ImageIndex property like so:
[Editor("System.Windows.Forms.Design.ImageIndexEditor, System.Design", typeof(UITypeEditor)]
public int ImageIndex
{
get { return imageIndex; }
set { imageIndex = value; }
} Here, imageIndex is a private field declared in your class to hold the value. Depending on how your component works, you may need to update the parent control.
If you don't follow these guidelines, you'll need to create your own UITypeEditor derivative.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks Heath Stewart
under your answer,I found an article from here
http://www.codeproject.com/cs/media/extimageindexconv.asp
the red line must been added;
[Category("Appearance"), <br />
Description("..."), DefaultValue(-1)]<br />
[<font color="#FF0000">TypeConverter(typeof(ImageIndexConverter)), </font><br />
Editor("System.Windows.Forms.Design.ImageIndexEditor", typeof(UITypeEditor))]<br />
public int ImageIndex<br />
{<br />
get <br />
{<br />
return _ImageIndex;<br />
}<br />
set<br />
{<br />
if (_ImageIndex = value)<br />
{<br />
_ImageIndex=value;<br />
}<br />
}<br />
}
I think if I changed the ImageIndexConverter to a Converter class which I designed , In desingn time , will it show my Converter in property grid?
|
|
|
|
|
That's the idea, yes. Just make sure you reference the Type (either using typeof or a string representation, which is handy when you want to have a separate design-time assembly like Microsoft does for most members) in the ConverterAttribute .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi all,
I would like to ask a question as below,
My software is composed of a main C# program with some other c# dll as components. In the first round, I will install all the stuff on the machine.
Then after sometime, I need to install some additional dll to work with
the main C# program. How can I do that ? Is that possible in C#.Net framework ?
The scenario is similiar to install Microsoft Office Suite, at the first time, I only install MS WORD with the MS Office main framework, but later I install also MS Excel (just like i install another DLL in my application)
onto the MS Office Main program on the PC.
Thanks
|
|
|
|
|
Yes it is possible but the initial design of your application will need to be carefully thought out. I'm actually working on a project that is very similar in nature to yours and we are using this method to develop more functionality to users over time and to patch specific parts of the system without actually going off-line.
The application we are writting is a trading application for different asset groups. We have a framework which compiles into an executable and all that framework does is authenticate the user again a database and see what permission the user has. GUI-wise the framework is just an MDI Parent window with a form that takes care of the login/authentication. When the user clicks on a menu only items that the user has permission to use appear as menu items. This is done with the combination of checking what DLL's are available on the remote server where all the DLL's reside on what the user has permission to access. So if a trader is an Equities trader he/she does not have access to Foreign Exchange screens/data so those images will not even appear inside the menu(s) of the framework.
All images that can run inside the framework are separate projects within the solution and produce DLL's into a common output directory (be careful because VS .NET is not too happy when you do this). When a bug is fixed and it's time to put the changes into the production system all we have to do is just move the newly updated DLL into a directory where the framework is expecting it and tell all the traders who need to use this updated image to close their existing image and open a new instance of it. I belive this is a very good way to design an application that will be used by many people since maintanance is very easy but on the down side it will take some time to "get it right" at first.
|
|
|
|
|
Yes,
" This is done with the combination of checking what DLL's are available on the remote server "
But I would like to know how to check what dll's are available on the remote server?
|
|
|
|
|
I'm following some of the tutorials at MSDN to embed Windows Media Player into my program. It's a simple problem. However, I can't seseem to get the controls to work. Even though I'm following the examples directly in the MSDN.
I declare the player and make it invisible and deactivate autostart:
private AxWMPLib.AxWindowsMediaPlayer axWindowsMediaPlayer1;
axWindowsMediaPlayer1.Visible=false;
axWindowsMediaPlayer1.settings.autoStart = false;
So that runs find. Then I open a dialog box, read a file and store it in the player:
axWindowsMediaPlayer1.URL = openFileDialog1.FileName;
So far so good. But when I try to run the controls it states that .controls is not part of the AxWMPLib.AxWindowsMediaPlayer. However, according to the documentation it clearly states at Microsoft that to stop I could...
axWindowsMediaPlayer1.controls.stop();
But the above code will not compile. I get the sneaking suspicion that somehow I'm messing up obkjects. Between all the player objects and media objects and everything else do I have the wrong object type?
I'm using WMP9 SDK. If anyone has a clue, or can give me a simple answer, I would be gretaly obliged.
|
|
|
|
|
I had the same problem, i looked and looked and found that it was changed to Player.Ctlcontrols
so try axWindowsMediaPlayer1.Ctlcontrols to find play, stop, ect..
modified 16-May-21 21:01pm.
|
|
|
|
|
I'll give that a try. Thanks...
Is it just me or does the MSDN archive suck?
|
|
|
|
|
There is another problem using Playlist.item[ index ] you will get an error, its also been cahnged to Playlist.get_Item[ index ]. All these problems have been documented in the WMP 10 SDK now which im playing with now.
modified 16-May-21 21:01pm.
|
|
|
|
|
Okay cool... Now, I have the wmp sdk 9. Haven't updated to ten yet. Should I just assume the commands in 10 are mostly right for 9. Because even the 9 commands don't seem to work. for example, in 9 it states I can use:
player.cdromCollection.item(index).eject()
but that doesn't work. I have problems with item. So instead I tried:
player.cdromCollection.getByDriveSpecifier(drive).eject(); That works fine.
|
|
|
|
|
Strange i just tried that and it worked ?
Player.cdromCollection.Item(0).eject();
I dont know if you cut and paste you code on the fourm but the "item" has to be "Item",uppercase I. Strange even in the WMP 9 SDK it has a lowercase 'i'.
Are you using Visual Studio .Net it should have that autocomplete feature so you can get the true objects (except that get_item, it doesnt show it?)
if not try borlands C# builder its free and just like VS. NET
modified 16-May-21 21:01pm.
|
|
|
|
|
Hi All,
I've written a Windows Service (c#) which contains config params in a app.config.
I now need to extend it to offer a means to change the app.config via a winform.
The Question
Is it possible to add a winform to the service so that if the user executes the service executable by file selection, then it be launched as a normal winform app rather than the service?
I started writing a seperate app, but obviously the two apps don't share the target config file. Anybody know a clever way around that one?
Thanks in advance...
Andy
|
|
|
|
|
What you can do is combine the source code of the two applications. You can modify the Main function so that it will launch a windows form when the user specifies a special command line parameter, otherwise it will start the windows service.
I haven't tried this myself, but it sounds pretty straight forward.
My articles and software tools
|
|
|
|
|
HHOOK h;<br />
LRESULT CALLBACK CallWndProc(int nCode,WPARAM wParam,LPARAM lParam)<br />
{<br />
<br />
switch(nCode)<br />
{<br />
case WM_SIZING:<br />
return 0;<br />
break;<br />
<br />
case WM_MOVING:<br />
return 0;<br />
break;<br />
<br />
default:<br />
return CallNextHookEx(h,nCode,wParam,lParam);<br />
}<br />
}<br />
void InstallHook()<br />
{<br />
h=SetWindowsHookEx(WH_CALLWNDPROC,CallWndProc,0,0);<br />
}
this code if made in mfc dll but i have 2 problems :
1- i dont know if the created DLL is created correctly or not
2- i used this DLL in another app and called InstallHook but a big msg appears said that there is no entry piont for the installhook in the dll
if anyone knows anything plz reply me
|
|
|
|
|
Perhaps if you post this on the Visual C++ forum[^] someone might be able to help.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Hello,
I have created a control, extending UserControl, called ColorMixer. Then, I created a small app, call it Host, to host that contol. I right-clicked Host, chose Add Reference, went to the projects tab, and selected my ColorMixer project. Automatically, ColorMixer appeared in the toolbox in the My User Controls tab.
Now, I wrote another control, ColorMixerWithArgs, and another host app, and did the same thing. However, ColorMixerWithArgs does not appear in my toolbox.
Does anyone know why? I would rather the control automatically appear like ColorMixer did than go to the My User Contolrs tab and add the dll manually.
Thanx,
-Flack
|
|
|
|
|
Unfortunately, you're pretty much at the mercy of Visual Studio .NET when it comes to this behavior. Sometimes it works; other times, it doesn't.
One thing to keep in mind, however, is that I doubt you'll be needing the control in the toolbox so often within a solution. If this is a control you use often, then finalize the code and "install" it on your machine as a third-party control is. Put a copy in the Global Assembly Cache (drag and drop it into %WINDIR%\assembly or use gacutil.exe -i <filename>) for run-time use, so you don't have to worry about re-locating the file for each project that uses it.
If you need to include this in a project in order to design it and it doesn't show up in the toolbox, just do what the designer does (which isn't really magic - it's just code that you can type as well). Add a declaration along with the rest toward the top of your class definition. Go into the InitializeComponent method (hidden in a region) and instantiate it like all the others and add it to the container control's Controls collection property. When you switch back to design view, you can begin designing it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
This is in regards to the AMS profile C# dll:
http://www.codeproject.com/csharp/ReadWriteXmlIni.asp
Is there any way to specify the path of the xml file to write the settings to? Below is the code I am trying to use, but I get the following error:
An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.
It occurs when I try to set a value using:
sPath = System.AppDomain.CurrentDomain.BaseDirectory + "/test.xml";
sPath = sPath.Replace("/","");
if ( System.IO.File.Exists(sPath) == false ) {
// create the xml file
System.IO.File.Create(sPath);
}
AMS.Profile.Xml oXml = new AMS.Profile.Xml(sPath);
oXml.SetValue("test","testone","cool!");
Thanks in advance!!
_invid
|
|
|
|
|
|
Heath is right, you should have posted this in the article's message board, but since we're here...
The most likely reason you're having the problem is because you're calling System.IO.File.Create(sPath), which creates the file and then locks it. This causes the XmlDocument.Load to fail.
The solution is simple: You don't need to worry about the file's existence. If it's not found, AMS.Profile will create it for you automatically. So just get rid of the "if" code and you'll be fine.
Regards,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|
Cool! Thanks!! Sorry bout posting here :/
|
|
|
|