|
Your user control can't have an AcceptButton property because what happens if there are multiple user controls on the same form and all have that property set? which is the one that counts?
A workaround is to expose a public read only property named something like DefaultButton , and have it return a reference to your OK Button . Then, the form can set its AcceptButton property to that reference. Or the other way around, make the form pass a reference to itself to the user control, so it can set the form's AcceptButton property (I like the first way better).
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Hi,
I would like to find an example of ruler control, does anyone have this experience ? I would like how to do ~, thanks !!
|
|
|
|
|
A ruler control is a pretty simple owner drawn control, I'm sure google will bring you some matches.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
thanks all of you, it should give me some hints
|
|
|
|
|
Hi :
How can I darg-drop item to a WebBrowser control ?
I created an application written by C#,it includes two forms , one form
includes a TreeView control , the other includes a WebBrower control and a
TextBox control, now we call them as Form1 and Form2.
First , I try drag a item to the TextBox control,(I have set TreeView for
drag well ) I set
"this.textBox1.AllowDrop = true;" then add Events and write these methods:
this.textBox1.DragOver += new System.Windows.Forms.DragEventHandler
(this.textBox1_DragOver);
this.textBox1.DragDrop += new System.Windows.Forms.DragEventHandler
(this.textBox1_DragDrop);
this.textBox1.DragEnter += new System.Windows.Forms.DragEventHandler
(this.textBox1_DragEnter);
Run this application,and drag item from TreeView which in Form1 to TextBox
which in Form2,the TextBox 3 Events (DragOver,DragDrop,DragEnter) is done
well.
But when I want drag item to the WebBrower,I can not find DragEnter Event and
others Events related to "Drag-Drop",so I can not drop Item to WebBrowser.
Also I have tryed set WebBrowser's Document.DesignMode="On",but can not drop
too.
Then I Write a HTMLBody's ondragenter Event ,but this ondragenter() can not
trigger.
So I think it must be solved by COM knowledge.
Can any one give my some suggestion,
because my COM knowledge is poor, if anyone give me an all solved code ,I
will be very appreciated.Thanks very
|
|
|
|
|
You can't drag and drop onto a web control. What were you hoping to drag and drop onto it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for your reply,well,I'm doing a HTMLEdit control writen by c#,and I want to drag a html tag item into this control,then I paste a tag html into this control.
Sorry for my poor English ,but I really want your help ,thanks
|
|
|
|
|
No need to apologise, I'm glad to help, but a WebBrowser control does not show HTML, it just renders it. And it doesn't support drag n drop.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If I add WebBrowser control in VB6.0 ,then I could drag items to it and drop,I think Com control to Com control is works ok ,but when add WebBrowser control in .net programe,it doesn't work.
You are right "WebBrowser control does not show HTML",but WebBrowser control has a DOM property,and use mshtml.HTMLDocument Interface ,I can control it's html,what I want to do is draging item into WebBrowser control,and when droped I add some html string into some where by mshtml.HTMLDocument interface.
If some one want simple code,I can send it to your Email adress,my email is cecilia_in_love@163.com .I really want help!
Also sorry for my poor English ,I'm not a English speaking country.
|
|
|
|
|
OK, I didn't know that the browser control had drag and drop at all. It's kind of weird, I mean, if you drag and drop a string, how will you know where in the DOM to put it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Greetings,
I've successfully implemented MS's control array as prescribed in this article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchcreatingcontrolarraysinvisualbasicnetvisualcnet.asp
But I would like to implement a two dimensional control array. I'm adding buttons to a series of tab pages, and I need to be able to address the buttons on each tab page.
Is it possible to modify the class provided in the article to support a second dimension? I'm a newbie at C# so I will need a few key lines of code which illustrate the modifications needed. Thanks.
|
|
|
|
|
if you need to access Button in tabPage you dont have to create array as when you add control to tabpage this control will be add to controls collection of tabPage
to access all the button in tabpage you can write somthing like
foreach(Control ctl in tabPage1.Controls)
{
if(ctl is Button)
{
Debug.WriteLine(ctl.Name);
}
}
MCAD
|
|
|
|
|
Hi
I need help as i have a usercontrol loaded at runtime on a main form .What i want to do is on click of a button on usercontrol i want to refresh the treeview control with fresh data on the main form and load other control on the main form. how can i do that.
thanks
monica
|
|
|
|
|
Set up a delegate which you call when the button is pressed, and which the main form ties to a method that refreshes the tree control.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
can u explain a bit more a give me some example site to have a look at it i am new to c#.net
thanks
|
|
|
|
|
Oh, you've made the leap from VB ? Congratulations !!
Here[^] is an online tutorial. Basically, your control contains a definition of an event ( a delegate ) and an instance of that type. It defaults to null, and when the button is pressed, if it's not null, it calls it. The main page sets this variable to be a function IN the main page which matches the definition. In this function, you refresh the tree view. This function is then called by your control whenever the button is pressed.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Christian
That tutorial is not elping me much. can u give a bit more details. Is it the way
i have declared a public delegate in the main form which i am calling in the click event of the button on usercontrol.
Thanks
monica
|
|
|
|
|
In the control:
public delegate void ClickEvent();
public ClickEvent RefreshTree = null;
inside the click event handler for the button in the control:
if (RefreshTree != null) RefreshTree();
in the mainform:
void RefreshEvent()
{
theTree.Invalidate();
}
inside the create method, just after the call to initialisecomponents:
theControl.RefreshTree = new ControlType.ClickEvent(this.RefreshEvent);
There are a few things that need renaming, but that's basically it. The control defines the event and an instance of it. The main form defines the method and ties it to the event. The control calls the event if it's been set when the button is pressed. The method that is called refreshes the tree.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
sorry to bother you again.
"inside the create method, just after the call to initialisecomponents:
theControl.RefreshTree = new ControlType.ClickEvent(this.RefreshEvent);"
i could not get the concept of this line.
where this line is to be written in the main form or in the control.
if i write this line inthe main form after the call to initialisecomponents.
PatientDetails.RefreshTree = new PatientDetails.ClickEvent(this.RefreshEvent);
where PatientDetails is my usercontrol and frmMain is my Main form.
it gives me this error
e:\PRJVITREORETINAL\frmMain.cs(54): An object reference is required for the nonstatic field, method, or property 'PRJVITREORETINAL.PatientDetails.RefreshTree'
thanks
monica
|
|
|
|
|
monica2k wrote:
where this line is to be written in the main form or in the control.
monica2k wrote:
if i write this line inthe main form after the call to initialisecomponents.
That's correct.
monica2k wrote:
An object reference is required for the nonstatic field, method, or property
You've put the class name, instead of the name of an instance of the class.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi Christian
i am writing these statements inthe usercontrol do i have to do anything else. this refreshtree always is coming null and doing nothing
public delegate void ClickEvent();
public ClickEvent RefreshTree = null;
private void button1_Click_1(object sender, System.EventArgs e)
{
if (RefreshTree != null) RefreshTree();
}
thanks
monica
|
|
|
|
|
Yeah, like I said:
in the mainform:
void RefreshEvent()
{
theTree.Invalidate();
}
inside the create method, just after the call to initialisecomponents:
theControl.RefreshTree = new ControlType.ClickEvent(this.RefreshEvent);
RefreshTree is just a name. You set the ClickEvent to be null, and when you check, it's still null. It needs to be give a value of a method in the main form.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi Christian
is there any other way to do that. i cannot make it to work.
thanks
monica
|
|
|
|
|
Hi monica. No, no there is no other way that I can think of. What part is not working for you ?
Christian Graus - Microsoft MVP - C++
|
|
|
|