|
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
|
|
|
|
|
How can i convert Hexadecimal into binary an vice versa
|
|
|
|
|
What does the first link show?[^]
Cheers,
Vikram. "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
|
|
|
|
|
Convert from hexadecimal to numeric, then from numeric to binary. The other ways goes... well... the other way...
---
b { font-weight: normal; }
|
|
|
|
|
Hi Friends,
If anybody knows the procedure to convert Julian time calendar date to dd-mm-yyyy format, plz help me.
Thanks,
Sandeep
+919891027854
|
|
|
|
|
Take a look here[^], or here[^].
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
at run time a create a table with 20 row , then set it to Datagrid but data grid also shows 21st extra row to enter data. How can i prevent that.
|
|
|
|
|
set the datagrid's ReadOnly property to true, or set the dataview's AllowNew property to false
|
|
|
|
|
|
Hi everybody,
I have a big problem with listbox . I created a user control which contains two listboxes and two buttons to permit switch a single or multiple items from listbox1 to listbox2.
When I click into vertical scrollbar (not on the track button but inside the scrollbar, it moves itself to place the selected item on bottom of the active listbox . My problem is that play only at the first time that I use the listbox (after the form load event)
I hope have clearly explain my problem and hope someone help me.
PLEASE.......... HELP ME !!!!!!!!!
Thanks for help.
X-TroLL
|
|
|
|
|
|
hi to all,
how can i put a link label in a listview cell ? and how to fire an event when i click the data in the cell ?
best regards and thanks in advance
fady
|
|
|
|
|
I have the following within my myWall Class:
<br />
private Point _wallLocation = null;<br />
<br />
public myWall(Point newLocation)<br />
{<br />
this._wallLocation = newLocation;<br />
}<br />
This returns a compile time error of:
Cannot convert null to 'System.Drawing.Point' because it is a value type
So I have to use one of the following two options and either make it:
<br />
private Point _wallLocation;<br />
or
<br />
private Point _wallLocation = new Point(1,1);<br />
I am new to C# (< 5 days) with a C background, so to me the first option isn't good because I have an unassigned variable kicking around. The second option isn't any good because I am wasting resources allocating a Point that I will never use.
What is the best way to allocate a ValueType that has nothing stored in it if I can't null it?
If I use the first example does that mean that the Point is actually allocated? If so does it have random data in it? This would imply that the two options above cost exactly the same processor wise.
Thanks.
-Rowan
|
|
|
|
|
Look at it this way.. Whenever you have a value type, like int, double, ..., or any struct (like the Point in your code), treat the thing as you would a normal variable which is not dynamically allocated. The value types are not allocated on the heap, as are all objects of classes in C#. But they are placed on the stack.
Assigning null to a reference object (an object of a class) derefences the memory, so that the gc can clean up the mem when there are no other reference to that particular memory. Since value types are not on the heap no cleaning up is necessary (they go out of scope).
Put it otherwise all objects of classes are pointers to these object, all objects of value types are just that the object itself.
You will need to initialize your Point with a default value if the (0,0)(which is the default) is not to your liking.
I hope this sheds some light to the issue for you.
Greetings
Davy
|
|
|
|
|
Hi,
Why do you not use a property ?
<br />
private Point _wallLocation;<br />
public Point WallLocation<br />
{<br />
get{return _wallLocation;}<br />
set{_wallLocation=value;}<br />
}<br />
<br />
And into your class constructor<br />
public Constructor()<br />
{<br />
_wallLocation = new Point(0, 0);<br />
}<br />
I think that the best solution because the Nullable type is not implemented in the .Net Framework 1.X but in 2.0 it does .
In .Net programming, you must allocate all variables having ValueType type.
I hope that help you
X-TroLL
|
|
|
|
|
-Rowan- wrote: the first option isn't good because I have an unassigned variable kicking around.
I don't think you need to bother about that - whenever you try to use something like _wallLocation.x , the compiler flags it as an error, so you won't get any nasty runtime surprises.
-Rowan- wrote: If I use the first example does that mean that the Point is actually allocated?
I'm a tyro myself, but I think the answer is No.
HTH.
Cheers,
Vikram. "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
|
|
|
|
|
Vikram A Punathambekar wrote: I'm a tyro myself, but I think the answer is No.
Actually, yes. This piece of code will compile and run fine
struct X
{
int y;
}
void SomeMethod()
{
X x;
x.y = 100;
Console.WriteLine(x.y);
}
The new operator for structs is only to initialize the struct's members to 0/null. Instead of that, if you take care of the initialization before using the struct, it'll work just fine.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
You're right, Senthil.
I was trying to print the member's value directly instead of assigning a value, and got an error. I assumed that it was because the variable was not created.
Cheers,
Vikram. "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
|
|
|
|
|
A value type is always allocated whenever it is in scope, that means that it always has a value. If you haven't assigned a value to it, the value is undefined (e.g. unknown or "random").
Most of the time, though, the compiler won't let you use a variable that has an undefined value.
The Point class has an IsEmpty property and an Empty field that you can use to specify an unassigned value:
private Point _wallLocation = Point.Empty;
The _wallLocation.IsEmpty property returns true when the location is undefined.
---
b { font-weight: normal; }
|
|
|
|
|
-Rowan- wrote: What is the best way to allocate a ValueType that has nothing stored in it if I can't null it?
If you're the author of the type, you could have a special static property to do that, something like
struct MyStruct
{
static MyStruct Empty
{
return new MyStruct(<Some Invalid Value>);
}
}
-Rowan- wrote: If I use the first example does that mean that the Point is actually allocated? If so does it have random data in it? This would imply that the two options above cost exactly the same processor wise.
Almost but not quite true. Your first example does result in a stack allocation. The compiler forces you to initialize all fields before using the instance, so you won't run into random data.
The second line of code causes the compiler to emit a .initobj IL instruction, which results in all fields in the struct being initialized to their default values.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi.
I have a website where i want to pass some values from one site to another.
my problem is that i store the values in an array, but the length must not be longer or shorter than needed.
example:
http://mywebsite.com/graph.aspx?item1=cat&item2=horse&item3=dog
string item1 = Page.Request.Params["item1"].ToString();
string item2 = Page.Request.Params["item2"].ToString();
string[] labels = { item1, item2, item3 };
but if the user inserts "&item4=cow" into the url, then it would give an error.
i need the labels array to extend so that it gets item4 if item4 exsist in the URL.
I new to this, please help me.
-- modified at 5:26 Wednesday 14th December, 2005
|
|
|
|