|
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
|
|
|
|
|
Hello Munty,
Muntyness wrote: should I just scrap it all and take up farming now?
I think this would be the best solution for everyone!
My suggestions are:
UserControl:
Maybe the SelectedIndexChanged Event is raised to often because of the "Items.Clear" and "Items.Add".
So a boolen flag in the SelectedIndexChanged Method could help.
private bool updating;
private void cmbl_SelectedIndexChanged(object sender, EventArgs e)
{
if(updating==false)
{
OldValue = Current;
Current = cmb1.Text;
.
.
.
}
}
private void p_ItemManager_ArrayChanged(object sender, EventArgs e)
{
updating = true;
.
.
.
updating = false;
}
ItemManager:
Have you used the GetInstance Methode?
The update Method looks much too complicated for working correct.
Why cant't you just add and remove directly from the Array?
See you!
Martin
|
|
|
|
|
Martin# wrote: ItemManager:
Have you used the GetInstance Methode?
Admittedly no. To be honest I wasn't sure what that method was for...
Martin# wrote: Why cant't you just add and remove directly from the Array?
I can directly remove from the array (it now does that ), it's just that when I add to the array, the items need to be ordered. So I can either put the value into the correct place to start with, or I can sort the array after the item has been added. I'm fairly sure that sorting the array after every change would probably be worse, but if it's better to sort, feel free to tell me.
the code now looks more like this:
(There are 2 combo boxes now, but the methods are identical except for some names)
private void cmb1_SelectedIndexChanged(object sender, EventArgs e)
{
OldValue1 = Current1;
Current1 = cmb1.Text;
if (OldValue1 != null && OldValue1 != Current1)
{
selected = 1;
ItemManager.update(OldValue1, cmb1.SelectedIndex);
}
}
void ItemManager_ArrayChanged(object sender, EventArgs e)
{
if (selected != 1)
cmb1.Items.Clear();
if (selected != 2)
cmb2.Items.Clear();
foreach (String st in p_ItemManager.AvailableItems)
{
if (selected != 1)
cmb1.Items.Add(st);
if (selected != 2)
cmb2.Items.Add(st);
}
selected = 0;
}
int the item manager:
public class fnt_ItemManager
{
public event EventHandler ArrayChanged;
private ArrayList _availableitems = new ArrayList();
private String Default;
public fnt_ItemManager(String defaultcont)
{
Default = defaultcont;
}
public ArrayList AvailableItems
{
get
{
return _availableitems;
}
set
{
if (value != _availableitems)
{
_availableitems = value;
}
}
}
public void update(String oldVal, int index)
{
Boolean found = false;
int i = 0;
if (index != 0)
{
AvailableItems.RemoveAt(index);
}
if (oldVal != Default)
{
foreach (String st in AvailableItems)
{
if (st.CompareTo(oldVal) > 0)
{
AvailableItems.Insert(i, oldVal);
found = true;
break;
}
i++;
}
if (oldVal != null && found == false)
{
AvailableItems.Add(oldVal);
}
}
if (ArrayChanged != null)
{
ArrayChanged(this, EventArgs.Empty);
}
}
}
It's better than before, but still buggy. (Go me!
- Munty
-- modified at 9:55 Tuesday 12th December, 2006
|
|
|
|
|
Hello Munty,
Muntyness wrote: Admittedly no. To be honest I wasn't sure what that method was for.
This Method generates only one instance of the fnt_ItemManager.
It's also static, so you do not need an instance of the class to call it.
Cause if you make a instance like this:
fnt_ItemManager p_ItemManager = new fnt_ItemManager();
Every Control has its one instance of the Manager and has no idea which item is used by an other Control.
So please implement the method like i did and call it from the Controls, like that:
fnt_ItemManager p_ItemManager = yourenamespace.fnt_ItemManager.GetInstance();
If no't all controlls are linked (sharing one set of items), please let me know.
We would have to make the GetInstance method more dynamic to create and return more than one instance.
Hope that helps!
All the best,
Martin
|
|
|
|
|
So that's what it does!
Hmm... I might try that when I next have some free time with the code (Which wont be till tommorow at the earliest)
At the moment I've just created the instance in the GUI that the user controls are added too. And then whenever the user adds another control, the ItemManager instance is passed into the new user control.
So it looks something like:
(In the create control method)
UserControl something = new UserControl(ItemManager);
And in the item manager, something like:
(In the user controls class)
private theItemManager itemManager;
public UserControl (theItemManager item)
{
itemManager = item;
}
(Incase you're wondering, I don't have the code infront of me right now)
And don't worry, all the controls are using one set of items.
Thanks for all the help you're giving me by the way.
- Munty
|
|
|
|
|
hi all,
I'm using oledb connection to read a dat file into dataset.
i've converted the dat file into txt file and created schema.ini file with |delimiter. It reads fine but my prob is no of rows count in the dataset is less than in the file(just only one row). Event i mentioned the hdr = no extended properties. Plz help
here i've given the sample code
public static DataSet FileReader(string Filename, bool SchemaRequired, DataSet dsCol)
{
string newFilename = "";
string filextn = Path.GetExtension(Filename).ToUpper();
string schemafile = "";
if(filextn == ".DAT")
{
// To change the File extension if the file type is DAT
newFilename = Path.ChangeExtension(Filename,"TXT");
File.Move(Filename,newFilename);
}
else
{
newFilename = Filename;
}
if(SchemaRequired)
{
//This Schema.ini file is required to read the text file with custom delimiters here we use(|)
schemafile = Path.GetDirectoryName(Filename)+@"\Schema.ini";
if(File.Exists(schemafile))
{
File.Delete(schemafile);
}
using(StreamWriter writer = File.CreateText(schemafile))
{
writer.WriteLine("["+Path.GetFileName(newFilename)+"]");
writer.WriteLine("Format = Delimited(|)");
for(int i = 1; i<= 19; i++)
writer.WriteLine("Col"+ i +"=C"+ i + " Text");
}
}
string PathtoTextFile = Path.GetDirectoryName(newFilename);
System.Data.OleDb.OleDbConnection oConn = new
System.Data.OleDb.OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + PathtoTextFile + ";" +
"Extended Properties=\"text;HDR=NO;FMT=Delimited\"");
System.Data.OleDb.OleDbDataAdapter oCmd = new System.Data.OleDb.OleDbDataAdapter(
"select * from "+Path.GetFileName(newFilename),oConn);
DataSet myDS = new DataSet();
try
{
oCmd.Fill(myDS);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return null;
}
finally
{
if(SchemaRequired)
File.Delete(schemafile);
if(filextn == ".DAT")
{
Filename = Path.ChangeExtension(newFilename, "DAT");
File.Move(newFilename,Filename);
}
}
return myDS;
}
|
|
|
|
|
public static void main()
{
try
{
//some exception occured
}
catch()
{
system.out.println(" ");
}
finnaly
{
system.out.println("hai");
}
system.out.println("hello");
}
is hello wud be printd or not
plz let me know asap
with regards
|
|
|
|
|
Why haven't you tried this out for yourself? You have most of the code there, so it is a simple matter for you to test it it, except for the fact that there is no System.Out.Println - that's a Java class. Change that to Console.WriteLine and put in a divide by zero error into the try block, and you will be good to go.
BTW - please don't put SMS speak into posts. This makes it harder for the person who is reading it to understand.
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.
|
|
|
|
|
Hi
Does anybody know where the Copy Local reference property is perstisted?? I assumed it would be in the project file, but I can't seem to find the defintion.
Thanks
|
|
|
|
|
Dear all,
currently, i am developing a project where i need to display the chart which i created in Windows Form into a webpage using C#, is it possible?
Besides, is there any way to automatically update the chart base on the latest data that get from internet (use TCPIP to host to the webpage and retrieve the latest info)?
Your help is greatly appreciated.
Thank you.
Sincerely,
Velerena
|
|
|
|