|
Unless I'm missing something, just call PerformClick():
private void button1_Click(object sender, System.EventArgs e) {
BusinessRules.PerformClick();
}
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Thank you.
The PerformClick is akin to SendMessage(). It takes place immediately.
I was hoping for a PostMessage()type behavior.
Any ideas?
thanks
|
|
|
|
|
I would like to set focus on the 1st control that does not have data.
For most controls I can ask in the text field is empty. But for checkboxes and radio buttons, I must ask for the special case of 'GetChecked'. If it was only these two types of controls the code below would be OK. But controls derived from Checkbox and Radio button would also need special case code.
How can I ask if a control is a checkbox or derived from a check box?
public void SetFocusOnFirstEmptyControl()
{
int iCount=0;
System.Windows.Forms.Control Traverse = this;
//System.Reflection
while(Traverse != null)
{
Debug.WriteLine(++iCount + " " + Traverse.Text );
if(Traverse.GetType() == typeof(System.Windows.Forms.CheckBox))
{//do special case handling for check box
System.Windows.Forms.CheckBox pCheck = Traverse;
if(pCheck.Checked()== false)
{
Traverse.Focus();
break;
}
}
if(Traverse.Text.Length == 0)
{//test controls like textbox and dropdown
Traverse.Focus();
break;
}
Traverse = GetNextControl(Traverse, true);
}//while
|
|
|
|
|
hi !
>How can I ask if a control is a checkbox or derived from a check box?
DERIVED FROM A CHECKBOX:
myControl.GetType().IsSubclassOf(typeof(CheckBox))
andi
|
|
|
|
|
|
Does this work if that class does not derive directly from CheckBox and CheckBox being its grand parent?
Mazy
No sig. available now.
|
|
|
|
|
yes.
to check wheter it is derived directly use:
myChild.GetType().BaseType.Equals(typeof(myFatherClass))
andi
|
|
|
|
|
Thanks
Mazy
No sig. available now.
|
|
|
|
|
i am a real noob to programming...
i have downloaded a demoproject, but how can i build the project? it gives error's.
project can be found on this link: http://www.thecodeproject.com/dotnet/simpledbreadwrite.asp
|
|
|
|
|
Probably the easiest way to solve your problem is to ask your question on the forum for the article (located at the bottom of the article page) and give the author the exact error you get and the particular section of code that it errors out on.
I passionately hate the idea of being with it, I think an artist has always to be out of step with his time.
-Orson Welles
|
|
|
|
|
|
i get this error:
------ Build started: Project: TestDbReadWrite, Configuration: Debug .NET ------
Preparing resources...
Updating references...
Performing main compilation...
c:\documents and settings\emiel hartman\mijn documenten\visual studio projects\cs\testdbreadwrite\mainconsole.cs(4,20): error CS0234: The type or namespace name 'ADO' does not exist in the class or namespace 'System.Data' (are you missing an assembly reference?)
Build complete -- 1 errors, 0 warnings
Building satellite assemblies...
Satellite assemblies could not be built because the main project output is missing.
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped
|
|
|
|
|
sorry for my "ahead-0" but I could not find a nice english word for that:
01, 001, ....
so the problem is my datagrid hides the 00 before an integer value. (so "001" becomes "1")
does any body know
1) a nice word for "ahead-0"
2) a solution for my problem
?!?!?
thank you.
andi
|
|
|
|
|
The English term is leading zero.
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
Hi,
I would appreciate very much if you could explain about frames.
If you inherit from (i think) SHDocVw.DWebBrowserEvents2 then there is an function called DocumentComplete witch get all frames in the control. Each time this function is called one frame is catched in the function argument until all frames are done. Well that for me was uncertain yesterday when I had problem with a website. I could not get the frame displayed in front of me. Then I found out that the frame in axWebBrowser control was not loaded in DocumentComplete and I had to add that to my array of frames. So could somebody explain if I had it all wrong thinking that 'ALL' documents or frames was grabbed in DocumentComplete.
Also is axWebBrowser.Document included or excluded in ((IHTMLDocument2)el).frames.length count ?
Sorry if you get the fealing that the text is written by an irritaded programmer. Well I can't help myself. Please write something encouraging.
Yours sincerely
Andla
|
|
|
|
|
Are you talking about the DocumentComplete( ... ) Event in Webbrowser control. In that case, this event is invoked by the webbrowser control after downloading the page. In you have more than one frame, this event may get fired more than once. Not every frame fires this event, but each frame that fires a DownloadBegin event fires a corresponding DocumentComplete event. The top-level frame fires the DocumentComplete in the end. So, to check if a page is done downloading, you need to check if the IDispatch* parameter is same as the IDispatch of the WebBrowser control. See the code below.
void CMyDlg::OnDocumentComplete(LPDISPATCH lpDisp,
VARIANT FAR* URL)
{
IUnknown* pUnk;
LPDISPATCH lpWBDisp;
HRESULT hr;
pUnk = m_webBrowser.GetControlUnknown();
ASSERT(pUnk);
hr = pUnk->QueryInterface(IID_IDispatch, (void**)&lpWBDisp);
ASSERT(SUCCEEDED(hr));
if (lpDisp == lpWBDisp )
{
// Top-level Window object, so document has been loaded
TRACE("Web document is finished downloading\n");
}
lpWBDisp->Release();
}
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Thanks for your answer.
The following I understand from your response:
Not every frame fires.
What frames does not fire ?
The toplevel frame fires when done.
Is toplevel the frame in WebBrowserControl.Document?
Is toplevel the main document?
In this case this does not get loaded sometimes.
Regards
Andla
|
|
|
|
|
I was able to do that. But there is a problem in pages where in certain cases only the inner frame is reloaded and the outer frame does not change. so essentially here documentcomplete is not fired for the top level only for the inner frame. eg - http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro[^] There, if you go to that link documentcomplete is fired for all, the last being for that url. But if you click on the button - 'edit and click me' documentcomplete is not fired for the top level. How can we work around this?
|
|
|
|
|
Hello, i'm using a dll with VC++ 6.0 i would like to use it with C#. My problem is that some type of data are not usable with c#.
For exemple i can use char *xx as parameter , but when i want to use a pointer on a structure, it seems impossible to have it working.
MyStruct
{ string field1;
int field2;
}
[DllImport(@"C:\DLL\MyDll.dll",EntryPoint="myfunction",CharSet=CharSet.Ansi)]
unsafe public static extern int myfunction(uint param1,short short param2, MyStruct *pointeronStruct);
It is not working,
[DllImport(@"C:\DLL\MyDll.dll",EntryPoint="ReadCard",CharSet=CharSet.Ansi)]
unsafe public static extern int SecondFunction(uint param1,short param2, byte *field1, int *field2);
so i need to split the structure, when there is only 2 fields, it's not a problem, but when you have 10 fields, it's not the same.
As i cannot modify the dll, i decided to include this dll in a dll where is solve thoses kind of problem and then use the new dll with .NET.
Does someone know how to solve this ?
Thanks by advance
|
|
|
|
|
I had a similar problem with a dll developed in Delphi, and using the same in VC++. First you will have to find out the equivalent data types in C# for all the parameters used in the dll. Most of the data types will be the same except for the structure. Declare a similar structure in C#, create an object of the same, and then pass the address of the object as a long value( which would get type casted automatically in the dll ).
Hope this would solve your problem.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Whenever I set some control's AllowDragDrop property to true, i get this error when I'm run the app. Any idea what this is and how to I solve it? Thanks.
God, I pity me! - Phoncible P. Bone
If I end up Windows ME someone is going to be hurting. - One of the answers to a question for What OS are you
|
|
|
|
|
Hi,
I am new in c# [coming from the java world] and am hitting a problem.
how to you pass callbacks to the com world. I have seen plenty of example using dll (for example using windows api from c#, etc) but not using com
I use an active x control into my UI.
everything goes well, included in project, displaying ok, etc...
now, this ocx graphic component allows me to register some callback so that my gui can be aware of some components events
for example, it implements:
public abstract new void addBrowserListener ( System.Object pListener )
and defines the interface
X3DBrowserListener
if I do
ocxComponent.addBrowserListener(new X3DBrowserListener()); compiles and runs ok but not really useful
the X3DBrowserListener interface defines:
public abstract new void browserChanged ( ANIMALib.X3DBrowserEvent @event )
Sadly I got a run time:
System.InvalidCastException: No such interface supported
at xxx.X3DBrowser.addBrowserListener(Object pListener)
at xxx..ctor() in b.addBrowserListener((X3DBrowserListener)bl);
if calling
ocxComponent.addBrowserListener(new MyX3DBrowserListener());
if I define my own class as
<br />
using System;<br />
<br />
namespace xxxxxxx<br />
{<br />
[CLSCompliantAttribute(false)]<br />
public class MyX3DBrowserListener:X3DBrowserListener<br />
{<br />
public void browserChanged(ANIMALib.X3DBrowserEvent ev){<br />
System.Console.Out.WriteLine("I am here");<br />
}<br />
}<br />
<br />
}<br />
}
help very welcome!!! or any pointer to com/c# callbacks codes or samples
Cheers
Olivier down under
|
|
|
|
|
Nazila Naderi wrote:
please help me
Hmm, my first suggestion is for you to read around. You might consider reading Clipboard handling with .NET[^]. I am not entirely clear where the file name is coming from (i.e., where you are dragging it from) so the clipboard might not be the direction you want to go. More detail is really needed to identify a solution here however I would highly suggest you start reading around.
-Nick Parker
|
|
|
|
|
This should do what you need:
private void Form1_Load(object sender, System.EventArgs e)
{
this.pictureBox1.AllowDrop = true;
}
private void pictureBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.All;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void pictureBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
string[] itemsInDrop = (string[])e.Data.GetData("FileDrop", false);
foreach (string path in itemsInDrop)
{
FileInfo CheckForImage = new FileInfo(path);
if(!CheckForImage.Exists)
{return;}
try
{
Bitmap newImage = new Bitmap(path);
this.pictureBox1.Image = newImage;
}
catch(System.ArgumentException)
{
MessageBox.Show("The file at " + path + " is not a valid image.", "Invalid Image", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
|
|
|
|
|
I have a statusbar which I have to draw custom panels onto inorder to changed the text color of the panel when an event happens. I add these panels in when a user does a certain action. I'm having a problem though. Everytime a new custom panel is added, it obviously re-draws the statusbar, but it changes all the panels to the same name. To try and correct this I added a foreach in, but all that did was change all the panels to the same name and write each name in the panels callection on top of each other. Any ideas on how I can solve this problem? -Thanks-
private void statusBar1_DrawItem(object sender, StatusBarDrawItemEventArgs sbdevent)
{
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
Graphics g = sbdevent.Graphics;
StatusBar sb = (StatusBar)sender;
RectangleF rectf = new RectangleF(sbdevent.Bounds.X, sbdevent.Bounds.Y, sbdevent.Bounds.Width, sbdevent.Bounds.Height);
g.DrawRectangle(p, sbdevent.Bounds);
foreach( StatusBarPanel panel in this.statusBar1.Panels )
{
g.DrawString( panel.Text, sb.Font, regularColor, rectf, sf );
}
}
|
|
|
|