|
|
ROFL... How the **** did I end up here.
Sorry guys. LOL.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
Hi,
Methods in an interface must be public?
If i have a public method in an interface, can i make this method "internal" (or any other access parameter) in a class derived from the interface?
ie:
public interface myinter
{
public void MyMethod(){}
}
public class myclass : myinter
{
internal void MyMethod(){//my code}
}
|
|
|
|
|
Heinz Suez wrote:
Methods in an interface must be public?
Yes, that is the point. It is defining the external interface* to something. In other words, it is defining the interface* (or part of the interface*) to your class that other classes use.
Heinz Suez wrote:
If i have a public method in an interface , can i make this method "internal" (or any other access parameter) in a class derived from the interface ?
No. You cannot. This is because the class would then no longer support the interface it advertises as supporting.
Do not confuse "interface" with the C# keyword "interface ". An interface is another way of saying how an external entity sees the class. You provide an interface with any public methods. An interface is a way of defining a common set of public methods or properties that a number of classes support.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
First of all your code won't compile
And yes all members of an interface must be public visible to everyone using this interface. But you can restrict them ONLY to explicit interface users:
public interface ITest
{
void TestA();
}
public class Class1 : ITest
{
void ITest.TestA() {}
}
static void Main()
{
Class1 c = new Class1();
c.TestA();
ITest t = c;
t.TestA();
}
|
|
|
|
|
I can't seem to figure out how to get the selected date from a MonthCalendar. The DateTime picker has a value property, but I can't find the same for the MonthCalendar. How do I get the selected date from the MonthCalendar?
Thanks
|
|
|
|
|
hope this helps,
add a dateselected handler and use the eventargst oget teh datetime of the selected data, then just use the datatime properties.
<br />
<br />
private void monthCalendar1_DateSelected(object sender, System.Windows.Forms.DateRangeEventArgs e)<br />
{<br />
this.textBox1.Text = "Date Selected: Start = " +<br />
e.Start.ToShortDateString() + " : End = " + e.End.ToShortDateString();<br />
}<br />
<br />
regs,
g00fy
|
|
|
|
|
Hi all, I have an application in C++ (unmanaged) that was built to use the IQueryCancelAutoPlay interface and the AllowAutoPlay function to allow the application to determine whether it wants to handle media inserted into the CD/DVD drive or let Windows AutoPlay the media.
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/ifaces/iquerycancelautoplay/iquerycancelautoplay.asp for details.
I want to create a C# application that would do this very same thing. Unfortunately, I have not been able to find anyone who has done this through Google or MSDN.
Would anyone have an idea of where to start? I.e., any methods of importing/invoking the interface into C# would be great.
Thank you!
C
|
|
|
|
|
I am trying to debug a Form. I set a breakpoint on a method and then started the debugger. Under the debug menu I added a Watch1
window. Then I went into MSDN help-- it says I can get the variables into the watch window by dragging them in. Tried a number of things (drag from class view, from Form, but I can't seem to get anything in. What the heck am I missing here -- thanks a lot....
ps- as you can judge from my post I'm a beginner so go easy.....
|
|
|
|
|
To drag and drop a variable, you first have to select it. Press ctrl (for word selection) and click on it. Then drag it.
In the code you can right click on a variable and add it to the watch.
You can just type the name of the variable in the watch window if everything else fails.
---
b { font-weight: normal; }
|
|
|
|
|
I'm not using an image list so this might not be so easily done, but I'm not sure. I'm making a Word Processor in C# using Visual Studio .NET 2003 Professional. But when I start to use some of the toolbar icons (bitmaps) they have a gray or silver background like the ones for bold, italic, right-align, and so forth. How do I get rid of that background color. Are there any icons like this that are free?
Thanks
|
|
|
|
|
Hi all,
I want to write some windows control by myself. I don't really have any idea how to do that actually. Maybe the easiest way would be combine several existing windows controls into one. Like a textbox, button and a calender. My problem is can any windows control be a potential container??
And also a more difficult problem is if I want to build a totally new windows control, what should I do?? Is using the graphics class the right way to go???
Thanks in advance!!!
Asura
|
|
|
|
|
There are generally two types of visual controls as far as .NET/Windows Forms is concerned. You have the Control, which is not a combination of other controls, but a class (and possible support classes) written with painting code, user input handling code, windows message handling code, etc. Then there is the UserControl, which is a simple form surface without a frame that you can combine multiple, existing controls onto, and which has its own, localized event handling loop.
If you just want to combine existing controls to make a reusable interface with say, a label, textbox, button, and filebrowserdialog, you could create a simple usercontrol that lets you browse for a path. You can create events, properties, and methods for this usercontrol, so you can interact with it and respond to it wherever you use it (i.e., on another form or even another user control).
Writing pure, custom controls is quite a bit more complex. You have to write the whole thing from scratch. That includes drawing every aspect of the visual representation, handling keyboard and mouse input, responding to windows messages, and generating events for when things happen on your control (i.e. the user clicked a certain part of the control, or they double-clicked it). Depending on exactly what kind of control your writing, you may need support classes and collections to store listed data, or if your writing a container control, you have to support child controls and proper placement of those child controls.
Custom controls also don't integrate well into the Visual Studio .NET designer unless you directly code for it. This means properly attributing your code to support he property editor, as well as attributing your code with custom type converters and visual designers. There is also the aspect of data binding for custom controls, which, suffice to say, adds a whole nother layer of complexity.
So, to put all that simply. If you have never written a custom control before, start with UserControls (they are a type of form you can create in VS.NET). Once you learn how to create complex user controls, and learn how to create and handle events from your user controls, you could move on to true custom controls. True custom controls, properly written to support the design time environment, data binding, and support interaction with other code (through properties, methods, and events), can easily take 10 times as much code or more than a UserControl. Writing custom controls is very fun, but pace yourself if you really want to learn them. UserControls are a perfect introduction to the world of custom controls.
|
|
|
|
|
Thank you very much for your article. It's very helpful for me.
Asura
|
|
|
|
|
Glad to be of service. If you have questions, feel free to email me. Writing custom controls is a hobby of mine, and I'm glad to give out tips and tricks.
|
|
|
|
|
Jon Rista is right. You can use winform controls like textboxes for creating your own controls. Just create a child class from the textbox class and add your custom events and members to your class.
|
|
|
|
|
Oh, actually, I spaced out subclassing. You can also derive a class from an existing control, nad augment/add to its functionality, like Heinz said. I still recomment starting with UserControls, but subclasses controls are a good intermediate step between UserControls and full custom controls.
|
|
|
|
|
Hi,
I've done a drag and drop of a sqlDataAdapter and generated a dataset on a second WinForm (Form2) I'm opening as a dialog box. I can bind to it and retrieve results but I get an error when I try to use any BindingContext.Count/Position methods on the dataset. Any help greatly appreciated.
Error: 'Cannot create a child list for field myTable.'
Code Snippet Follows:=======================================
try
{
int iCnt;
iCnt = this.BindingContext[this.dsExtPhyLookup1, "tblExternalPhysicians"].Count;
}
catch(Exception exp)
{
MessageBox.Show(exp.Message.ToString());
}
|
|
|
|
|
hi all,
i need to pass a record between forms. i got it working for now, but i don't think it's right.
1st. form has a read only datagrid bound to a dataset.
2nd. on double-click event, i'm currently looping through col values
3rd. send individual col values to new form.
i don't think this is right (and yes, i'm a newbie) cause if i'm using locale then the value in the col on the grid would be a converted value and not necessarily the value in the dataset right?
how can i pass the record from the dataset to a form (best practice) use a structure?
tia
|
|
|
|
|
I assume you want to transfer the data of the current row or something similar.
One apporach would be to fill a structure or little helper class which you can pass around. Another idea would be to transfer the whole DataRow object (DataTable.Rows[currentRowIndex]).
|
|
|
|
|
excellent, i started down the structure path. thanks for such a quick response!
|
|
|
|
|
I'm trying to read numbers from a TextBox and convert them. Even though I have
a number in the TextBox the compiler can't convert. Which got me thinking about the above question....thanks
|
|
|
|
|
Convert.ToInt32(string value) internally calls Int32.Parse(string s) so it doesn't matter which one you call.
What makes you think it doesn't work? Are you probably trying something like Convert.ToInt32(textbox) instead of Convert.ToInt32(textbox.Text)? Or is the string probably not fitting into an integer?
|
|
|
|
|
toint32 takes 1 arguement
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemConvertClassToInt32Topic13.asp
parse takes 2
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemInt32ClassParseTopic3.asp
i might be missing something, but couldn't you also trap the keypress event and verify your numeric's there?
if(char.IsNumber(e.KeyChar) == false)
e.Handled = true;
|
|
|
|