|
I did actualy and it does arrive at the other form. Yeah i figured it has something to do with the 2nd value being set to "".
Thanx Chris! Looks like I'l be following ur path since im self-studying as well. I've no idea whatsoever on programming and being an intern in a company gave me the opportunity to initialize my technical skills...interesting...how did I get to c#? Oh well! Thanks again! Till my next stupid post!
Kampai!!!
|
|
|
|
|
tatchung wrote:
Yeah i figured it has something to do with the 2nd value being set to "".
That should really just cause the SQL to do nothing, I'd have thought.
tatchung wrote:
I've no idea whatsoever on programming and being an intern in a company gave me the opportunity to initialize my technical skills
What's an intern, is it like an entry level position ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
intern = ojt = on the job trainee.
I'm a management student but the only opening i got for my ojt was this programmer position. So as you can see...it really is hard for me to study under certain conditions given by the company and intense time pressure pressed by some of our clients. But don't get me wrong...I enjoy working my mind in programming and i enjoy programming per se. It sorts of develop self awareness and of course...my chess skills!
Kampai!!!
|
|
|
|
|
OK - I see. I've heard the term often, but wasn't sure what it meant. Management->programming, that's quite a leap. Good luck with it all !!!
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanx! I'd make good on this!
Congratulations on your acheivements Chris and Gud luck to you in the future! Till my next post!
Kampai!!!
|
|
|
|
|
Hey Chris! I was wonderin if you could spare a minute of ur time to help me out with this simple problem.
Regarding the delete button we've discussed before...yeah i finally made it work but there's just one slight problem...I've 2 entries in my dropdown list..."CompanyA" and "CompanyB" where "CompanyA" populates the top index of the dropdown list. Now everything works smoothly even the delete button but when I choose "CompanyB" and delete a data from its queries it deletes a data from with the same object from "CompanyA". I've been bugging the whole day about this problem. Here's my new code in the delete button
if (Page.Request.QueryString["Mode"] == "Delete")<br />
{<br />
objCol.DeleteColors(Page.Request.QueryString["key"],ddl.SelectedItem.Text);<br />
}
I've tried debugging and used "? ddl.SelectedItem.Text" (i'm not sure what that is called) which still retuned "CompanyA" even though I chose "CompanyB".
Thanx in advance!
I didnt create a new thread...figured u'd reply faster here. Hehe...sori for the inconvinience.
Kampai!!!
|
|
|
|
|
Looks to me like you databind with your data source on postback, which will reset the item selected.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I get the name of the control in string format in an event: "control1"
And I want to modify its properties (for ex.: control1.BackColor = Color.White;
How can I convert or point this string to the existing instance of the control??
regards
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
Reflection.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thanks Christian but it's a huge namespace for me to solve this issue right now. I tried PropertyInfo and checked the MemberInfo classes but still found no answers.
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
You're saying that reflection is a huge space to learn, or that you're working in a huge namespace ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I meant the Reflection namespace is huge but still I need to learn that. It's just that it's 5 am and I have a little time to finish what I'm writing. that's all.
Anyway, thanks for the help..
I think I should use MemberInfo class and tried smth like this:
<br />
System.Reflection.MemberInfo[] myMembers = ....GetType().GetMember("pictureBox1");<br />
this.Controls.Remove(myMembers[0]);<br />
on it..
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
No, I don't think that's the way to go. Sorry, I don't know a lot more, but definately reflection is the only way you'll get variables out of names, unless you build a hash table before you start and look it up.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hmm.. if only there was an equivalent like java's eval function... but no..
thanx for your time
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
Well friend I don't have fancy solution like reflection but this should do the trick... I bet 90% of people are using it... hey -> not all of us are MVPs ... NHF? I'm just kidding
<br />
foreach (Control c in this.Controls)<br />
{<br />
if (c.Name == "control1")<br />
{<br />
}<br />
}<br />
Now if ur's event isn't in form which control u need to modify, than you'll need to pass that form, or it's collection Controls. Drop a line if u need more hints...
|
|
|
|
|
I thought about this method but I need to do it without loops.. It will slow down the app...
thanks anyway.
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
you may
use reflection to get the type by name
and then call InvokeMember
|
|
|
|
|
Not sure if this'll compile, but I've done something similar to this:
<br />
string controlname = "control1";<br />
string propertyname = "BackColor";<br />
object newvalue = Color.Black;<br />
Control control;<br />
<br />
control = form1.GetType().InvokeMember( controlname, BindingFlags.Instance|BindingFlags.GetField, null, form1, new object[] {} );<br />
control.GetType().InvokeMember( propertyname, BindingFlags.Instance|BindingFlags.SetProperty, null, control, new object[] { newvalue } );<br />
--
Joel Lucsy
|
|
|
|
|
Hi All,
Just wondering if there is a way to change code access permissions (is that the right phrase?) from within the actual code at runtime?
Is this possible? I am writing some network tools and the network I am on has restrictions on .NET applications running. I was need to temporarily give the code access to certain areas of the system and then once the job is done, remove them.
Thanks for the help, sorry if this is a really noob question.
|
|
|
|
|
No, there is no way to elevate permissions at runtime (huge security risk!)
You can, however, sign your code with a certificate, then trust your certificate. You could also add the site you're running the app from (either network share or off the web) to your Internet Explorer trusted sites list, which, I believe, should get your code full permissions.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Homosexuality in Christianity
Judah Himango
|
|
|
|
|
"huge security risk!"........ I thought as much, just wanted to make sure though. Thanks for the answer... unfortunately certificates are not going to work for this setup because the tool will be run remotely and will just e-mail out specific user information to the administrators mailbox... hmm perhaps there is another way to go about this. I will keep hunting. Thanks for all the help.
Timbobsteve
|
|
|
|
|
Hi,
I've been trying to get some 3D graphics into my C# application - I'm fairly familiar with using DirectX in C# and have created a few 3D applications in windowed and fullscreen modes etc... however...
I'm now trying to call DX9 (Summer 2004) from within a Custom Control - so instead of creating a full-sized WinForm device (or a fullscreen device), I create a control that can just be dragged onto any other WinForm application and hey-presto - there's my DX device ready to draw. (I'm kindof taking a cue here from the use of OpenGL and MFC within the same window, whereby you create the gl device from the HDC of an MFC picture control or similar...)
Anyway.
I create a simple DX app that simply creates a device, overrides the OnPaint and draws some objects etc - which works fine as a standalone WinForm application. I then created a Custom Control - override the OnCreateControl function to call some device initialisation code, override the OnPaint method as I've always done.. but the problem comes with then inserting the newly compiled control dll into a new winform app. Although the control inserts correctly, it then (of course) starts drawing whilst inside the IDE - this would be fine but then the whole lot becomes unresponsive (whilst the DX device contiunes to redraw), meaning that I can't resize, reposition my control, build, compile or do anything apart from giving the three fingered salute and neglecting to tell MS about my problem....
I'm not thrashing the processor (VS.NET 2003 only clocks %2 whilst in this unresponsive state), and Task Manager still thinks that VS is responding (until I try and do anything of use with it...)
Has anyone else tried doing this? Is it a reasonable thing to expect to be able to do? Thoughts or comments - I can post some code up if needed: not particularly exciting but gives an idea of what I'm trying to do.
Thanks,
benw
|
|
|
|
|
Why not just put some flag in that would only render if that flag is set to true. Have the flag set to false by default, that way you can begin rendering only when you explicitly start rendering.
I believe there are some design-time attributes you can set on your control to determine whether you're in design mode or not...I'm no expert there, but you might want to look into System.Windows.Forms.Design[er]
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Homosexuality in Christianity
Judah Himango
|
|
|
|
|
How does one pull a pattern matched keys from within a large Hashtable? I have a large System.Collections.Hashtable with over 2000+ entries within its mass. This table is constantly changing and can not be pushed outside of memory. Oh I wish I could push this to a SQL DB. My first thought was to foreach the Hashtable and build an array filled with keys each time the Hashtable changed. Then search the array. But there has to be a better way.
Any suggestions? I'll even take a laugh.
- - - -
Using this small example, I need to pull out a list of those entries within Hashtable listed below, all keys that start with “tom”, giving me just entries [0] and [3].
<br />
Entries within my Hashtable (short list) <br />
[0] tommy object<br />
[1] frang object<br />
[2] fratiti object<br />
[3] tom object<br />
[4] eddtom object<br />
[5] frankie object<br />
[6] blue object<br />
- - - -
|
|
|
|
|
Hi Dewclaws,
A Hastable is not the right collection for your problem.
How does a hashtable works
A hashtable build a array with N bags: bag #0 .. bag #N-1.
If you add a (key;value)-pair in the hashtable, the hashtable first compute the hashcode of you key.
For this it uses key.GetHashCode().
Than its arrange the hashcode in one of the bags. In most cases if it uses the bag #(hashcode%N).
In the bag, its store the pair of key and value. In a bag can be more than one pair.
If you search a value of a key, the hashtable compute the hashcode again and looks only in this one bag.
Example with 5 Bags:
Key Hashcode Bag
tommy 23 -> 3
frang 43 -> 3
fratiti 12 -> 2
tom 45 -> 0
eddtom 23 -> 3
frankie 67 -> 2
blue 56 -> 1
bag #0: (tom;object)
bag #1: (blue;object)
bag #2: (fratiti;object)
bag #3: (tommy;object) (frang;object) (eddtom;object)
bag #4:
If you select N large enough (about 1x..1.5x the number of keys) you have a mean search cost of O(n).
Solution 1
A solution is to use one sorted list of pairs or two sorted list of keys respectively values.
ArrayList keys = new ArrayList();
ArrayList values = new ArrayList();
public void Insert(string key, object value)
{
int index = keys.BinarySearch(key);
if (index >= 0)
{
values[index] = value;
}
else
{
keys.Insert(~index, key);
values.Insert(~index, value);
}
}
If you search all (key;value)-pairs in which the key starts with a special string use binary search again.
public struct Range { public int From; public To };
public Range Find(string keyStart)
{
Range range;
range.From = keys.BinarySearch(keyStart);
range.To = keys.BinarySearch(keyStart + char.MaxValue);
if (range.From < 0) range.From = ~range.From;
if (range.To < 0) range.To = ~range.To - 1;
return range;
}
Solution 2
Build a search tree.
The root node contains for each letter (symbol) at the first position a subnode. Each subnode for each letter (symbol) at the second position a subnode. And so on.
This solution is a bit faster than Solution 1, but a lot more complex to implement.
Example:
[ROOT]
|- b
| '-----------------> (blue;object)
|- e
| '-----------------> (eddtom;object)
|- f
| '-r
| '-a
| |-n
| | |-g
| | | '---------> (frang;object)
| | '-k
| | '---------> (frankie;object)
| '-t
| '-----------> (fratiti;object)
'- t
'-o
'-m
|-------------> (tom;object)
'-m
'-----------> (tommy;object)
If you search for the keys which starts with tom, you walk the path t-o-m and select all subnodes.
Solution 3
If you look for all keys, which contains a string in any position, you can walk throw the full list.
Hope, one solution helps you.
Niedzi
|
|
|
|