|
Anonymous wrote:
I want to get the Form at run time, the code suggested is for design time only
Thats the beauty of it though, the way it works is that at design time it gets assigned a reference to the form. Then when the Form designer goes to generate the code to recreate the component it sees that the property referencing the Form is not equal to the default value (null) so it serializes the property as a reference to the Form.
Even though the code to get the reference happens at design time, the reference is persisted by the designer. Then at run-time, when InitializeComponent is called on the Form it will reassign the reference to match the design-time state of the component.
Unfortunately this does no good if you want an easy solution for non-VS.NET/SharpDevelop users. As far as I know, there isn't any way to get the parent control that is hosting the component. And I'm not sure if there should be either because Components can be used anywhere, not necessarily used in conjunction with a Control/Form.
Sorry if I rambled, or didn't make sense I'm extremely tired and was just about to go to bed when I decided to check my e-mail.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
|
On a .NET Toolbar, how do I setup groups of buttons, such that only one button in a group is pressed. For example, if I have 3 different view modes, each represented by a button on the toolbar, how do I ensure that only one is pressed (sunk) at a time? Is there a property I can set, or do I need to code it?
Thanks in advance.
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|
|
Does anyone know how to spawn a command with a set of environment variables?
I am using Process which does seem to have:
p.StartInfo.EnvironmentVariables
But it is read only, or only has a get function.
|
|
|
|
|
|
.Add()
Ok I feel dumb...
Thanks!
|
|
|
|
|
You need to set them BEFORE creating the process object.
ProcessStartInfo pinfo = new ProcessStartInfo(emuPath);
pinfo.EnvironmentVariables.Add("TERM", "cygwin");
p = Process.Start(pinfo);
p.Start();
I see dumb people
|
|
|
|
|
Hi,
for my textboxes the following function works just fine when i set the keypreview of the form to true, and call this function in the keypressed event of the form:
public static void MoveNext(Form current_form, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
e.Handled = true;
current_form.SelectNextControl(current_form.ActiveControl,true,true,true,true);
}
}
As expected focus jumps to the next control.
But if the focus sits on a combobox, i just get a beep but it doesn't change focus. Now, if i put the code IN the KeyPressed event of the combo it does jump to the next control, but it still beeps.
Anyone have any ideas on how to solve this? The method of putting it insiode the keypressed event of the combo would be good enough for me atm, if it wasn't for that beep every time.
thanks,
Kristof
|
|
|
|
|
While I've been playing with the ComboBox (Inheriting from it) I've noticed that the "Key" Events do not work as you would expect them to for say a normal TextBox. It seems as if the Edit window of the Combo gets it's chance to process the Key event even before it gets passed to the Combo's Key Events.
For example, I am writing code for AutoComplete functionality. I wanted the control to only allow the user to type what was already in the List. However, when I tell it "e.Handled = True", it does absolutely nothing and still allows the user to type in the value. This is NOT what happens in a Textbox, the Textbox works as expected.
So...you probably aren't going to find a way to get rid of the Beep, but if you do, or you figure out my issue, Post it!
|
|
|
|
|
Had anyone have written a BHO in C#?
I need help in many ares.
If someone can point me a link to code or send me one I will be very thankful.
|
|
|
|
|
I am writing a little utility for Windows XP, and need to be able to use fast user switching. What function do I call? What library is it in? (I know this is a P/Invoke thing)
|
|
|
|
|
In C++, if you write the following:
printf("Number: 0x%04X", 1);
The output will be:
Number: 0x0001
As one can see, the number is prepended with a zeros. How do you achieve the same with C#?
|
|
|
|
|
|
|
Or in one step :-
inx x = 100;
System.Console.WriteLine("Number is 0x{0:X4}", x);
|
|
|
|
|
|
What/HOw would I use a HICON equivilant in .NET
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
|
I'm a beginer in VS.NET. I have a problem with copying a tree (in C#).
Copying seems to be OK, but no node appears in the treeview on the main form.
Pls find attached code.
I suspect the solution might be easy...
Many thanks for help in advance.
----------- code -----------------
public class MYForm : System.Windows.Forms.Form
{
private System.Windows.Forms.TreeView treeView;
......
static void Main()
{
// the main from
MYForm myForm = new MYForm();
// the "virtual" tree
TreeView mytreeview = new TreeView();
TreeNode mytreenode = new TreeNode("bear");
mytreeview.Nodes.Add(mytreenode);
...........
// tree copying to tree on the main form ????????????????????
myForm.TreeView = mytreeview;
myForm.ShowDialog();
myForm.Dispose()
}
}
misiek
|
|
|
|
|
|
It's not working (compilation error).
myForm.TreeView.Nodes.Add( arg );
arg must be string type;
But thanks for trying to help me.
misiek
|
|
|
|
|
I'm trying to disable a rich text box but still allow it to receive focus. Setting the enabled property to false, prevents the text box from receiving focus. I can currently disable key input to the rich text box, which is part of my solution so far.
But when a rich text box receives focus, a flashing cursor appears ready for the user to input text. Does anyone know how a rich text box can receive focus, but without the flashing cursor?
thank u!
|
|
|
|
|
Does anyone know how I can Register an ActiveX DLL or OCX using .NET Code? I don't care if it's Managed or UnManaged. Thanks!
|
|
|
|
|
You could try:
System.Diagnostics.Process.Start("regsvr32.exe",
string.Format("/s \"{0}\"", Path To Dll or OCX)) You can't always guarantee that the user will have regsvr32.exe on their machine, though.
If you know the file you want to register at compile time, you could use:
[System.Runtime.InteropServices.DllImport("Dll or OCX name", EntryPoint="DllRegisterServer")]
static extern int RegisterMyDll();
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
This is what I ended up doing but I had hoped someone could tell me why the following Code will not work!? I had code to do this and it works great in VB6! However, for some reason, .NET cannot get the "Address" of the Entry point for "DllRegisterServer" in my DLL (even though I know it is there)...it ALWAYS Returns "0". I will not know the name of the DLL ahead of time, so although I like your idea, it won't work in this situation.
Below is my code, taken from the API Guide example. The MSDN Help shows a different example (do a Search on "Register") of the Source Code of "Regsvr32.exe" but that does not work either, instead it just GPFs on me. However, even that code works in VB6.
Sorry for the VB references but it is what I had before and I am trying to convert it to C#.
'Declarations
Private Declare Auto Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Integer) As Integer
Private Declare Ansi Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Integer
Private Declare Auto Function GetProcAddress Lib "kernel32" (ByVal hModule As Integer, ByVal lpProcName As String) As IntPtr
Private Declare Ansi Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal PrevWndFunc As IntPtr, ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Public Sub RegisterFile(ByVal File As String)
Dim hLib, hResult As Integer
Dim hAddress As IntPtr
hLib = Me.LoadLibrary(_Path)
hAddress = Me.GetProcAddress(hLib, "DllRegisterServer")
hResult = Me.CallWindowProc(hAddress, 0, 0, 0, 0)
hResult = Me.FreeLibrary(hLib)
End Sub
|
|
|
|