|
Aha, thanks, is it overloading then?
notsnoj
|
|
|
|
|
Yes, the constructor is just another method that can be overloaded.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Well, overloading is also polymorphism, it's compile time polymorphism, as opposed to virtual functions, which offers runtime polymorphism.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I'm trying to load a sorted list from a database in Access. Would I put my loop statements in the constructor? Sorry for dumb questions, but we're learning this on our own. NO help from my professor as she doesn't know C#!
Like so?
VB
Public Class Contacts
Private contact As New contact
Public ContactList As New SortedList
Public Sub LoadFile(ByVal ds As DataSet)
Try
Dim tbl As DataTable = ds.Tables(0)
Dim row As DataRow
For Each row In tbl.Rows
contact = New Contact
With contact
C# - I know the dim and such isn't correct syntax, getting frustrated! Got to learn C# in 1 week!
private Contact myContact = new Contact();
public SortedList ContactList = new SortedList();
public Contacts()
{
Dim tbl As DataTable = ds.Tables(0)
Dim row As DataRow
For Each row In tbl.Rows
contact = New Contact
}
|
|
|
|
|
Here's what you need to do.
Before you continue with the problem, do the following--
Make sure you REALLY know --
If I have this--
class Boo
{
private:
int x;
int y;
}
1. How big is a Boo object? That is-- If I say "Boo b" -- how big is a Boo?
2. Were I to "instantiate" a Boo "object" where would I do that?
3. Is "class Boo" and object? (I think not....)
Hope this helps...
|
|
|
|
|
I have been tasked with creating a custom MenuItem. I can easily derive a class from System.Windows.Forms.MenuItem and add some methods to it. However, where I am having a problem is adding drag/drop capability. I need to be able to drag a MenuItem onto a toolbar. MenuItems do not support the DoDragDrop method which is what I would normally use. Is it possible to add DragDropEffects to a MenuItem?
Thanks,
Bill
|
|
|
|
|
You can fake it pretty easily. When the MenuItem catches a mouseDown, change the cursor of the MenuItem and the main application to something that looks like a cursor with a drag item. Then set your desired receiver's state to 'RECEIVING'. When the receiving control catches a mouseUp and it's in the 'RECEIVING' state, it will perform the operation just as if the MenuItem was really dragged. Now just set the cursor for the MenuItem and main application back to default.
|
|
|
|
|
if_mel_yes_else_no wrote:
You can fake it pretty easily. When the MenuItem catches a mouseDown
The problem is that a MenuItem doesn't have standard MouseDown/Up/Move events. It just has a Click event whose parameter is a plain System.EventArgs not MouseEventArgs so I don't have access to the information that would be in MouseEventArgs. Without being able to detect if I have a left or right-click or if the Ctrl key is pressed I don't see how to tell the difference between a normal click on a MenuItem and the click that is to start the drag operation.
Thanks,
Bill
|
|
|
|
|
You must be using studio 2003. In studio 2005 the MenuItems have all the mouse events. There's a chance that you could look into having the application catch any system mouseDowns, and using the mouseEventArgs's X and Y coordinates, try to figure out if it came from your menuItem... but that sounds like a lot of hassle.
How about a seperate menu item called "Add Bla". After you click it the cursor changes as I said before, and you can click on the receiver. It's not exactly a drag so much as a 'click to place', but it's better than nothing.
|
|
|
|
|
Yes, I am using studio 2003. I think we will wait for the final release of studio 2005 before adding drag & drop to our menus.
Thanks for your help,
Bill
|
|
|
|
|
I wrote a program with a whole bunch of tabs and each tab has subtabs with a bunch of controls in them. I distributed the program inside my company and some users complained that the text is cutoff on some controls. I asked for a snapshot and what happens is that the text wraps around on some of the controls and since the users are not aware of the wrap around feature to them it looks like the text is cut-off on top and on bottom.
Any ideas on how I can fix this problem so my GUI looks the same on all computers?
|
|
|
|
|
Welcome to the world of compatability. Trying to get an application to look the same on all computers is near impossible unless everyone in the company has the same type of operating system. If you're using studio 2005 and C# then the tab control's headers should auto-size to the length of the text. In 2003 I think you have to set auto-size yourself, either that or there will be a property called WordWrap that you can set to false.
|
|
|
|
|
Thanks for the reply; however, my main problem is that the text in miscellaneous controls such as checkboxes and labels are getting wrapped around even though they look fine on some computers.
Reason I mentioned about the tabs and subtabs is that I have way to many controls to modify them one by one, so I am hoping there is some method to make the GUI look the same on all PCs.
Your input about the OS is very good, I will check to see if that is the reason. Hope that's it because eventually everyone should go to XP.
Thanks.
|
|
|
|
|
Make your app check the screen resolution and inform users if it's too low. Or, find out the lowest screen res your users have, and develop at that res.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks Christian, I should be able to get feedback on the resolution of all the users who are having problem and hopefully I can see a pattern to solve the problem.
Regards,
Rudy.
|
|
|
|
|
hi,
the text in the rich textbox is underlined!
when i enter a key in the textbox i want to have FontStyle.Regular:
<br />
private void textBox_Receivers_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)<br />
{<br />
textBox_Receivers.SelectionStart = 0;<br />
textBox_Receivers.SelectionLength = textBox_Receivers.ToString().Length;<br />
textBox_Receivers.SelectionFont = new Font("Arial",8,FontStyle.Regular);<br />
}<br />
but when i enter only the one char (the one which i pressed) is in the textbox...why, the other text is cleared!? whats wrong?
cu
-- modified at 16:31 Tuesday 30th August, 2005
|
|
|
|
|
The text box is doing exactly what all text boxes do when all the text is selected and you insert a letter. It takes the selected text and replaces it whith the new letter. You really shouldn't be surprised by your results.
If you want to change the font and attach the new letter, then you need to clear your selected text before you leave the method.
|
|
|
|
|
|
SelectionLength = 0;
That's the first thing that came to my mind. There are also arguments in the 'e' parameter that you can use. Cancel pretends the keydown never happend, sometimes called Suppress.
|
|
|
|
|
<br />
private void textBox_Receivers_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)<br />
{<br />
textBox_Receivers.SelectionStart = 0;<br />
textBox_Receivers.SelectionLength = textBox_Receivers.Text.Length;<br />
textBox_Receivers.SelectionFont = new Font("Arial",8,FontStyle.Regular);<br />
textBox_Receivers.SelectionLength = 0; <br />
}<br />
doesn't work...hm
cu
|
|
|
|
|
richTextBox1.SelectionStart = 0;
richTextBox1.SelectionLength = richTextBox1.Text.Length;
richTextBox1.SelectionFont = new Font("Arial", 8, FontStyle.Bold);
richTextBox1.SelectionStart = richTextBox1.Text.Length;
richTextBox1.SelectionLength = 0;
This works fine when I do it.
|
|
|
|
|
hi, thx perfect, but i have a problem
if i select the whole text in the richtextbox and press clear or backspace then the whole text isn't cleared...hmmm!?
but i think i also can do that with Rtf, i mean that with underline...? how?
i saw:
<br />
textBox_Receivers.Rtf ...<br />
by the time i like c# *hehe*
cu
|
|
|
|
|
Rtf is just the same text but with the formatting codes included. You would never want to set the font on your Rtf. The codes will never be seen. If you're asking how to do underline, it's part of the FontStyle just like Regular and Bold.
|
|
|
|
|
if i select all the text in the richtextbox and if i press clear or backspace then all the text isn't cleared...hmmm!?
why?
cu
|
|
|
|
|
Come on, that one is pretty obvious don't you think?
|
|
|
|