|
Hey, sorry about that. Change the body of the FlagAsNotLoaded method to
m_InitializedForms.Remove( formType.Name ); Sorry, was removing on the Type and not the Type.Name .
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Now that I think about your solution, you may want to change all the references to formType.Name to one of two things: formType.FullName or formType . Two instances of different classes can have the same formType.Name and exist in the same project. If I include the two form classes Project1.CurtisAwesomeForm and Project2.CurtisAwesomeForm, then they will both have the same Type.Name s but different Type.FullName s and their Type s will not equate, either.
Just my two cents. <smile />
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
You have a been a huge help. Thanks a lot. It is good to see that there are still people out there willing to help without makeing such a fuss if there is a loss of understanding.
|
|
|
|
|
No problem, amigo.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Curtis,
I am trying to control the number of instances of each form as well. So, working off of the previous code, I added this:
public static void LoadFormType(Type formType, Form parentForm, int instances)
{
lock( typeof( FormLoader ) )
{
if( eh == null )
{
eh = new EventHandler( FormClosed );
}
}
if( IsAlreadyLoaded( formType ) )
{
Form f = GetForm( formType );
f.Focus();
f.BringToFront();
return;
}
Form frm = (Form)Activator.CreateInstance(formType);
FlagAsLoaded( formType, frm, instances );//
DictionaryEntry[] myArr = new DictionaryEntry[m_InitializedForms.Count];//added
m_InitializedForms.CopyTo( myArr, 0 );//added
if(myArr[m_InitializedForms[formType.FullName]].Value <= instances)//added, clearly the cast types are wrong, but you get the idea
{
frm.Closed += eh;
frm.Show();
}
}
private static void FlagAsLoaded( Type formType, Form f, int instances )//
{
m_InitializedForms[formType.FullName] = f;
m_InitializedForms.Add(f, instances);//added
}
Then I would load a form as such:
FormLoader.LoadFormType(typeof(Form2), this, 1);
"1" indicating how many instances of the form should be allowed.
Thanks again for your help.
-- modified at 8:31 Monday 19th December, 2005
|
|
|
|
|
I have just found out about the BITS protocol and think it would be perfect for the project I'm working on (an application that uploads large amounts of data to a server). The problem is that there doesn't seem to exist an BITS API for C#, just for C++. Has anyone created a wrapper for C#? If not, do you think it's difficult to do?
/Tubby
|
|
|
|
|
You could make a managed C++ wrapper around the original C++ code. This shouldn't be very hard to do, but you need to know some C++ to get it done
WM.
What about weapons of mass-construction?
|
|
|
|
|
Hi,
I'm trying to use the same event for different textboxes - the only difference being the textbox name.
Is there a way to determine which textbox the mouse has entered in a MouseEnter event, and then be able to do things with it like
Graphics g = txtBox.CreateGraphics();<br />
SizeF size = g.MeasureString(txtBox.Text,fontsmal);
?
Thanks so much again!!!
Mel
|
|
|
|
|
Yes, the sender paarameter in the event handler is the textbox that sent the event
private void AllTextBoxes_MouseEnter(object sender, MouseEventArgs e)
{
TextBox tb = sender as textBox;
if(tb != null)
{
}
}
|
|
|
|
|
|
The first argument to MouseEnter event "(object sender, EventArgs e)", sender is the control that triggered that event.
|
|
|
|
|
Hi guys,
I am facing problem with Gridview of Vs 2005 (in C#).
let me explain you whole.
I simply want to edit the gridview.I want to edit one selected row and into particular row exact column,but problem is that i m getting old values of that field like in orderqty field i want to change the No of order from 4 to 6 but when i am tring to retrive the value of that field it's giving me old value 4 instead of 6.
i had bound the gridview as same as we are generally binding with datagrid.
so can anybody help me out?
thanks
regards,
Montu3377
|
|
|
|
|
hi to all,
i need to define a form that will alyaws be on top of all other forms in my application.
i did that by setting the property TopMost = true.
the problem is that when i go into another win application (windows explorer for example) my form is still on top.
does someone knows how to define the form as a TopMost form but only for the c# application.
best regards and thanks in advance
fady
|
|
|
|
|
Hi,
You can try YourFormObject.BringToFront(). It will leave your form on top over all other forms of your application but you can access to another application without problems.
I hope that helps you.
X-TroLL
|
|
|
|
|
Hi. I am a newbie in programming C#, and am having a mental block. I am programming for the pocketPC.
I have a Combobox named "Type" and have a list there. I want to show the results of the entry from the combobox into a text label.
For example,
I pick "fruit" from the combobox.
I want to display on the screen: "This food is a fruit"
If I pick "vegetable" from the combobox, it should display:
"This food is a vegetable"
Right now, I'm getting:
"This food is a 1"
"This food is a 2"
How can I make the 2 into vegetable?
This is what I have, and I have a feeling it has to do with the GetValue and/or GetOrdinal.... I just can't seem to get it to work....
TypeLabel.Text = rReader.GetValue(rReader.GetOrdinal("MovieType")).ToString();
Thanks... Sorry for such a dumb question. If I haven't given you enough code, let me know. I can always add more.
|
|
|
|
|
try this
on comboBox1_SelectedIndexChanged event write this code
this.textBox1.Text = this.comboBox1.Text;
//each item u select from combobox the text of selected index should appear in textbox
I hope this helps
|
|
|
|
|
Thank you so much!
I will try it out immediately and let you know!
Thanks again!
|
|
|
|
|
Never Mind dude we are here to helps each-others
|
|
|
|
|
Okay, I thought I understood what I'm doing, but it's not really working.
I added this:
this.GLabel.Text = this.TypeCombo.Text;
To the Windows Form Designer generated code.
I added this:
OnTypeCombo_SelectedIndexChanged "1" write male;
It gives me the following error:
Invalid token "1" in class, struct, or interface member declaration.
|
|
|
|
|
Hello!
Oh my bad...try this in windows for designer:
this.combobox1.SelectedIndexChanged += new System.EventHandler(this.combobox1_SelectedIndexChanged);
then have this code inside the EventArgs:
this.Label.Text = this.combobox1.SelectedItem.Text
hope that works
Aim small, miss small...
-- modified at 1:02 Thursday 15th December, 2005
|
|
|
|
|
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.textBox1.Text = this.comboBox1.Text;
}
//this code must work, i tested multiple time and works fine.
I hope u fill combobox in onLoad Event of ur Form or u fill combobox from another event
|
|
|
|
|
Thanks guys!
Off to the new "challenge"!!!!
|
|
|
|
|
Well, it worked. Thanks again.
I have another problem, errr, challenge now. I am using an SQL database to save the info the person chooses on one form (pedbone.cs).
Here's the code to the Combobox I've got on the "main" form (pedbone.cs):
m_cTypes = new ArrayList();<br />
m_cTypes.Add("Unknown"); <br />
m_cTypes.Add("Male");<br />
m_cTypes.Add("Female");<br />
TypeCombo.DataSource = m_cTypes;
These are listed in a ListView
<br />
SqlCeCommand sqlLoadEvents = m_cConn.CreateCommand();<br />
sqlLoadEvents.CommandText = szSQL;<br />
SqlCeDataReader rReader = sqlLoadEvents.ExecuteReader();<br />
<br />
while ( rReader.Read() )<br />
{<br />
lvItem.SubItems.Add(GetTypeFromNumber ((int)rReader.GetValue(rReader.GetOrdinal("MovieType"))));
CollectionList.Items.Add( lvItem );<br />
}<br />
}
And here I got the Combobox text to show in the ListView, by using this code
private string GetTypeFromNumber(int nTypeID)<br />
{<br />
return (m_cTypes[nTypeID].ToString());<br />
}
Now, when you click on the listview item, a new form opens up (AddEditMovieForm.cs) to view the file in more detail. And here's where I'm running into a bit of a bind.
public AddEditMovieForm(SqlCeConnection cConn, int nMovieID)<br />
{<br />
InitializeComponent();<br />
<br />
m_cConn = cConn;<br />
m_nMovieID = nMovieID;<br />
m_cTypes = new ArrayList();<br />
<br />
if ( m_nMovieID != -1 )<br />
{<br />
SqlCeCommand sqlCommand = m_cConn.CreateCommand();<br />
sqlCommand.CommandText = "SELECT * FROM MOVIE_MNGR_TABLE where MovieID = "+m_nMovieID.ToString();<br />
<br />
<br />
SqlCeDataReader rReader = sqlCommand.ExecuteReader();<br />
if ( rReader.Read() )<br />
{<br />
<br />
}<br />
<br />
{<br />
<br />
GenderLabel.Text = rReader.GetValue(rReader.GetOrdinal("MovieType")).ToString();
<br />
{<br />
}<br />
}<br />
<br />
<br />
}<br />
}
Any help would be appreciated. I would like to add "male" or "female" into the GenderLabel.Text field. If I neglected to add any important code, please let me know.
Thanks guys,
M.
-- modified at 14:30 Thursday 15th December, 2005
|
|
|
|
|
I am working on classlibrary project in which I have to write a class which supports both oracle as well as sqlserver.Which Data object i should use?
-- modified at 7:09 Wednesday 14th December, 2005
|
|
|
|
|
Hi,
You can use a Factory which uses two object like this :
the following objects inherite of DataObject (your main class)
- DataObjectOracle
- DataObjectSqlServer
Your main class : DataObject will be used by an object DataObjectFactory
Your new object DataObjectFactory will be used by all your objects whose need access to database. In your factory object you must declare a method which must be static and have a parameter type of string.
Parameter contains the name of your wanted object.
For more information see the following link which demonstrate by picture my thing : http://www.dofactory.com/Patterns/PatternPrototype.aspx
X-TroLL
|
|
|
|