|
there should be two function available called SuspendLayout and ResumeLayout .
hope this helps...
V.
No hurries, no worries
|
|
|
|
|
Hi every 1,
I have a project in which I am using DataGridView and I have to show ContextMenu on the grid.
The problem I am facing is, I need either the Index of the cell where the user "Right Clicks" or get it selected some how... The reason I can't do it is that the when I assign context menu to the DataGridView it takes over the RightClick event of the DataGridView meaning that it will never be fired.
If any1 can suggest a feasible solution to it I will be great full.
o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°
|
|
|
|
|
|
Thanks Robert
You really saved my day..
ThaNKS AGAIN
o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°
|
|
|
|
|
Hi,
I'm trying to check if a certain tabpage is selected.
This is how i tried it:
foreach (TabPage tabControl in this.tabControl1)
{
if (this.tbp1)
{
}
}
I didn't find any property which represents "selected" for this.tbp1.
And i also got an error in the foreach statement which says:
foreach statement cannot operate on variables of type 'System.Windows.Forms.TabControl' because 'System.Windows.Forms.TabControl' does not contain a public definition for 'GetEnumerator'
How can i iterate through my tabpages in a tabControl and check if a certain tabpage is selected or active?
Thanks in advance!
|
|
|
|
|
Hello,
You have to compare the Index property of the TabPage, and the SelectedIndex property of the TabControl.
foreach (TabPage tp in this.tabControl1.TabPages)
{
if(tp.Index == this.SelectedIndex)
{
}
}
Hope that helps!
All the best,
Martin
|
|
|
|
|
Bulls eye!![Big Grin | :-D](https://www.codeproject.com/script/Forums/Images/smiley_biggrin.gif)
|
|
|
|
|
Hi,
try using TabControl.SelectedTab .
Robert
|
|
|
|
|
Hi guys,
I thank all of you for your reply!
But what Robert suggested did the trick
Thank you !
|
|
|
|
|
you can use the Selected or Clicked event of the tabPage (not the tab control) you can access this by selecting the tab control then go to the properties panel and on the top of the panel click on the drop down arrow and select the name of you tab page that u want to iterate. then select the events and select any event you wish
Good luck
|
|
|
|
|
|
People, who took their time for helping you and answered you two days ago, will not be happy.
|
|
|
|
|
rs2006 wrote: But I couldn't see the red line,I don't know why.
You were given a solution before. It didn't completely work but it got you further than your code above - Why did you revert to code that you know does not work in any situation when you had code that does work in some situations? Doing this is a slap in the face to anyone that tried to help you the first time round.
What you need is some way to keep the lines you draw on the form there permanently. You can do this by having the form respond to an OnPaint event and have it redraw the line every time the form gets damaged.
An alternative solution is to create a control that represents the line and have that draw itself when instructed.
|
|
|
|
|
it didn't show cz the panel is not painted unless the form is loaded cz the initializeComponents() method the is used by the compiler to paint and draw all the controls is not called unless the form is painted.
So u can't draw and paint on an undrawn and unpainted control
|
|
|
|
|
quiteSmart wrote: it didn't show cz the panel is not painted unless the form is loaded
He was actually told that a wee while ago. He obviously didn't listen.
|
|
|
|
|
Argggh. I hate it when they don't listen.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Some people need to hear the same thing twice to understand it well
so take it easy guys
don't hit him on his first fault
|
|
|
|
|
your welcome
but please look at the answers to your posts cz as i have read from the above replies that they answered u before on the same question.
no need to dosplay the question twice on this discussion board.
this will get some people upset
|
|
|
|
|
quiteSmart wrote: cz
quiteSmart wrote: but please look at the answers to your posts cz as i have read from the above replies that they answered u before on the same question
I really don't understand. Are you saying that I've asked the same question multiple times in different threads?
|
|
|
|
|
Alrighty then, my new question is this:
I have a combo box in each user control, and I have several user controls. Now I want each combo box to start off with the same options availible to them, (e.g. Mike, 1, 2, 3, 4, 5. I know how to do this part.) but when an option other than Mike is chosen in a combo box, then none of the other combo boxes can choose that option.
So if ComboBox1 has selected 1, then ComboBox2 will only be able to select Mike, 2, 3, 4, 5. But if ComboBox1 has Mike selected, ComboBox2 will still be able to select Mike, 1, 2, 3, 4, 5.
Anyway, I think I can put something together using handlers and arrays to do this, however I was hoping that someone knew a better way (or better yet knew if there was an article about this).
I hope I made sense. Any help will be appreciated.
Edit:
Here's how I would go about the code for this function.
In the Master class (The one that's creating the User controls) there is an array (Array1) with the combo box values. There is a second array (Array2) with the values that haven't been used. Array2 is passed into the User controls on creation, allowing them to populate their combo boxes.
In the User control there is also public method which updates the contents of the Combo box.
Now in order to get the combo boxes to update on all of the other User controls, a handler is put in the User control that listens for when the combo box is changed. This handler passes the contents of the combo box from both before(Value1) and after(Value2) the change (probably useing variables in the User class) to the Master class (which has a handle listening for the User control handler).
The Master class then removes Value2 from Array2. Then the Master class adds Value1 to Array2. Once this is done the Master passes Array2 into the public methods of all user controls, which forces them to update their Combo Box contents. Note that when placing Value1 into the array, a while loop would be used in order to have it placed in the appropriate position.
I really hope that explanation made sense.
- Munty
-- modified at 5:47 Monday 11th December, 2006
|
|
|
|
|
Hello,
Thats what I would try to do:
I would implement an "ItemManager" which holds the Array of available Items.
This Manager has an event ItemsChanged which is raised if the Array is changed.
The UserControls then get the Instance (Only one instance for all Controls) of the Manager.
They also link to the event.
If then a item is selected in a combobox it has to be removed from the Array of the manager and the olditem has to be added again.
If the ItemsChanged Event of the Manager is raised, the UserControls have too rearange their available items.
Hope that helps!
All the best,
Martin
|
|
|
|
|
Just one question.
I was assuming that ItemManager was a built in class, but as I can't find it, I'm now assuming that you meant I should make an Item manager myself. Other than that, I'm planning on trying that out sometime today.
- Munty
|
|
|
|
|
Muntyness wrote: I'm now assuming that you meant I should make an Item manager myself.
Yes that's correct.
I was thinking of something like that:
public class ItemManager
{
private static ItemManager _instance;
private Array _availableitems = new Array();
public ItemManager()
{
}
public Array AvailableItems
{
get
{
return _availableitems;
}
set
{
if(value!=_availableitems)
{
_availableitems = value;
}
}
}
public static ItemManager GetInstance()
{
if(_instance==null)
{
_instance = new ItemManager();
}
return _instance;
}
}
Hope that helps!
All the best,
Martin
|
|
|
|
|
Aye, that helps alot.
Thanks!
- Munty
|
|
|
|
|
Alrighty, Im here to bug you again.
So I took your framework and butchered it. (What can I say? I'm stupid )
public class fnt_ItemManager
{
public event EventHandler ArrayChanged;
private Array _availableitems;
public fnt_ItemManager()
{
}
public Array AvailableItems
{
get
{
return _availableitems;
}
set
{
if (value != _availableitems)
{
_availableitems = value;
}
}
}
public void update (String oldVal, String newVal)
{
ArrayList updating = new ArrayList();
int i = 1;
if (oldVal != null)
{
foreach (String st in _availableitems)
{
if (newVal != st || newVal == "#NONE")
{
updating.Add(st);
}
}
if (oldVal != "#NONE")
{
Boolean found = false;
while (i < updating.Count)
{
if (int.Parse((String)updating[i]) > int.Parse(oldVal))
{
updating.Insert(i, oldVal);
found = true;
break;
}
i++;
}
if (oldVal != null && found == false)
{
updating.Add(oldVal);
}
}
String[] rar = new String[updating.Count];
i = 0;
foreach (String st in updating)
{
rar[i] = st;
i++;
}
_availableitems = rar;
if (ArrayChanged != null)
{
ArrayChanged(this, EventArgs.Empty);
}
}
}
}
}
And in the control that calls it:
private void cmb1_SelectedIndexChanged(object sender, EventArgs e)
{
OldValue = Current;
Current = cmb1.Text;
if (OldValue != null && OldValue != Current)
{
ItemManager.update(OldValue, Current);
}
}
void p_ItemManager_ArrayChanged(object sender, EventArgs e)
{
cmb1.Items.Clear();
foreach (String st in p_ItemManager.AvailableItems)
{
cmb1.Items.Add(st);
}
}
Now then, this actually works for the most part, however it's kinda iffy (seems to call all the handlers in the control class twice). Plus in the combo boxes, while the code see's the values that are in the boxes, people can't. So the code would see that the box contained "5", however I'm only seeing "". Kinda iffy once again.
Sooo, is this worth keeping, or should I just scrap it all and take up farming now?
- Munty
|
|
|
|