The Catalyst wrote:
True, but they are all read only. None of them implement a set method
That's wrong. Look at the Point.X for example. You can set it.
The Catalyst wrote:
True, but they are all read only. None of them implement a set method
That's wrong. Look at the Point.X for example. You can set it.
Hi, ActiveForm is a static property of the Form class that returns currently activated form for the application but not the acitve frmMain instance. So in some cases you try to bind child form to the non-MDI-parent form. To have access to your frmMain form from all your classes you can add static property to it (as in the Singleton pattern):
class frmMain
{
private static frmMain current;
public static frmMain Current
{
get
{
return current;
}
}
public frmMain()
{
// constructor logic here
current = this;
}
}
Then you can use this property to construct your MDI-child forms:
childForm.MDIParent = frmMain.Current;
Then I think you should leave this menu logic in the specific view and don't burden Presenter with it. Presenter must describe the logic which is common for all views.
I think the difference between tab-focus and mouseclick-focus is: 1. When control receives focus by pressing tab the only one action occurs -- receiving focus. At this moment you select all the text and cursor automatically goes to the end of the text. 2. When control receives focus by clicking into the control there are two actions: At first you have behaviour as described at 1. But then control must move cursor to the position where you clicked within the control. And this movement clears the selection. (It looks like you select control with tab and then press arrow key to move cursor within the control.) I don't think you can prevent this behaviour for the common winform textbox without overriding mouse events.
Hi, Johnny. This CellMouseDown event handler should work:
private void dataGridView_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if ((e.RowIndex >= 0) && (e.ColumnIndex >= 0))
{
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true;
}
}
1. Add ToolStripContainer (from Toolbox) to your form. 2. Set toolStripContainer.Dock = All. 3. Add MenuStrip (from Toolbox) to the top of the toolStripContainer. 4. Select menuStrip and type captions for your menu items. 5. Select menu item and add handler to its Click event. 6. Repeat step 5 for all menu items.
Make your new event public and use ObsoleteAttribute with two parameters. In this case compiler will return an error when somebody try to use this event.
[Obsolete("SelectedIndexChanged is obsolete. Use MyNewEvent instead.", true)]
public new event EventHandler SelectedIndexChanged;
It doesn't work because you're calling static method add() using object instance. You needn't create object to call add() method:
public int calling(int x, int y)
{
return add(x,y);
}
And you even needn't create object to sum up your numbers:
public static void Main()
{
Console.WriteLine("enter x -->> ");
int x = int.Parse(Console.ReadLine());
Console.WriteLine("enter y -->> ");
int y = int.Parse(Console.ReadLine());
int sum = test.add(x,y);
Console.WriteLine("the value is --> {0}",sum);
}
Hi, RK. I think System.Drawing.SystemColors class can help you.
Hi, Judah. 1. Is ShowOurContextMenu() a part of your IView interface? 2. Does your Presenter know about myMenuItem or this is a private part of your view? 3. Does this behaviour common for all views or it is specific only for the concrete view?
Hi, KC.
KrunalC wrote:
I have overridden the getfocus behaviour
It's better to override OnEnter() method because you have a side effect with your code in OnGotFocus() (1. enter some text into your textbox; 2. go to an another form 3; go back to your form. After this your text will be fully selected. It's not a correct behaviour (although IE uses it in the address bar)).
KrunalC wrote:
I could write the above code in the click event of custom control by overriding the base implementation for click but i don't want to do that
I think you have to do that. But override OnMouseDown() instead of OnClick(). It will be more common behaviour. And you'll have to add some logic there to prevent selection when control already has focus.
ma se wrote:
I don't think there is a tabbed control in .NET 2.0??
You can find it on the "All Windows Forms" tab in the Toolbox.
You should set tabControl.SelectedIndex instead of using tabPage.Show() method.
Hi, Salmani. To set your application according to screen resolution you can use System.Windows.Forms.Screen class which provides information about all displays on the system.
Where do you take data for the struct instances? If data are taken from a database then you can create constructor with one parameter (record identifier) and load data within this constructor. Or you can add Load(int id) method to your struct. If data are random then you can add FillRandom() method. And so on.
Hi, Aruna. 1. treeview.HideSelection = false. 2. You can a) set form.AcceptButton = btnSend if your form is a dialog or you can b) handle KeyDown event of the textbox:
private void textbox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
// Handle Enter here.
}
}
You can use a transparent (TransparencyKey = BackColor) form above your panel.
Hi, Mahesh. If you want to create a classic MDI application then you shouldn't use SplitterPanel in your main form. You just need to follow next steps: 1. Set MainForm.IsMdiContainer = true. 2. Add a TreeView to the MainForm and set treeView.Dock = Left. 3. Add a Splitter to the MainForm and set splitter.Dock = Left. 4. When you need to create MDI child use this:
ChildForm child = new ChildForm();
child.MdiParent = this;
child.Show();
You should use panels to do this. You must have at least two panels on your form. If you use VS 2005 than you can simply use SplitContainer control. If not then: 1. Add panel1 to the form and set panel1.Dock = Top. 2. Add splitter1 to the form and set splitter1.Dock = Top. 3. Add panel2 to the form and set panel2.Dock = Fill. 4. Add treeview1 to the panel1 and set treeview1.Dock = Left. 5. Add splitter2 to the panel1 and set splitter2.Dock = Left. 6. Add listbox1 to the panel1 and set listbox1.Dock = Fill. 7. Do steps 4-6 for the panel2.
Hi, do you use AxWebBrowser? If yes then webBrowser.Navigate("some.mht", ...) will do this work.