|
yeah, ignore my "Me" comment, too. I include too much.
Okay, write the second handler without typing "combobox1" or "combobox2". My controls are located in ListArrays. I can only refer to them by knowing what their index is.
So in comboBox_SelectedIndexChanged(Object sender, EventArgs e), I need to know which of my two comboboxes is executing. "sender" turns out to be the combobox you clicked on, UNLESS you actually clicked on ComboBox1 and the code therein caused the DataSource for ComboBox2 to change. At that point, ComboBox2 receives a "SelectedIndexChanged" message, whose "sender" is ComboBox1.
So - in comboBox_SelectedIndexChanged(Object sender, EventArgs e) - how can you figure out which control is having it's Selected Index changed, without referring to it by name?
|
|
|
|
|
I would need to see a sample of this happening. What I'm saying is that if the SelectedIndexChanged is being fired for the ComboBox2 (because of a DataSource change or any other reason) then the sender will always be ComboBox2. This is hard-coded into the .Net framework.
I think there is something else wrong in your code. The sender will always be the ComboBox that had it's selected index changed (regardless of whether the user clicked in the first ComboBox or not). So there must be a problem with how the events are hooked up or with something else being done before the event is fired.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Sorry! My bug. I was binding the same handler to two different combo types. I gotta stop working all night.
So then - I can always use "sender" to know which control instance received the event? Yay! I can go to bed now!
|
|
|
|
|
Oh, and thanks. I'm tired, so I'm not being as clear as I should be.
BTW, if you know any better way to find out who "the current control" is in my case than what I am doing ("I don't have a reference for myself, so here, find Sender in this ArrayList and return me the Index"), I'd take it. That feels very obtuse to me...
Good night!
|
|
|
|
|
If it's always one main ComboBox to one secondary ComboBox, then I would use a Dictionary[^]. This way you can use the first ComboBox as the Key, then quickly obtain the secondary ComboBox (which would be the value).
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
I wish. It's an arbitrary number of "rows", each of which is composed of 10 controls.
I keep 10 ArrayLists(), one for each "column" in each row. Each ArrayList contains the control that goes in that "column" at that "row" (Index).
So at every point in my code where I need to refer to those controls, I use
. ((TypeOfControl)aNameOfArray[RowNum]).Property
Each column of controls shares an event handler. To find out which control is actually being fired upon, I have to use this:
. int i =aNameOfArray.IndexOf((TypeOfControl)sender);
Now that I have "i" (the index of this control in that specific ArrayList), I can use it to manage the other controls in that "row".
It doesn't seem so bad now, but while I was struggling with that bug I desparately wished for a shortcut like "thisControl" which I could refer to...
What would make life easier would be if ArrayList allowed multiple dimensions. However, it's really a Collection and apparently Collections don't allow that.
|
|
|
|
|
To acheive multiple dimensions you can have an ArrayList of ArrayLists. If you are using .Net 2.0 then I would recommend using a List[^].
For your problem above, I would probably create a main ArrayList that holds ArrayLists. So for each row of controls you would create an ArrayList and add your controls, then add that ArrayList to the main ArrayList in the proper position.
Then to determine what row a given control exists in, I would use a Dictionary. Declared as "Dictionary<control, int32="">", the dictionary would map a control to it's associated row in the main ArrayList.
This way you could easily add additional controls to the row without having to create a new ArrayList.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
FYI every Control has a Tag property (type: object), so you can store one reference there
to whatever you like. One ComboBox could point to another ComboBox, to an ArrayList, whatever.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I would always assume that sender is the control instance that "fired" the event. The form is the one receiving the event. I use the word "assume", because it's really up to the person who coded the control. For the .Net framework controls, I have never seen an instance were sender was not the associated control. If there is then it would probably be considered a bug.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
How to extract html code any web site using C#.Net
I mean : http://www.yahoo.com----in that site find the Urls,Emailid,phone
Pls give code
Reddy
|
|
|
|
|
Grabbing the HTML is easy, the rest probably involves regular expressions to parse the string that contains the page.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
allivelu wrote: How to extract html code any web site using C#.Net
I mean : http://www.yahoo.com----in that site find the Urls,Emailid,phone
I'm not sure exactly what you want. If you are looking to get the HTML for a webpage, load it in a WebBrowser object and use the DocumentText property to retrieve the HTML as a string.
If you are looking for the URLs, email, and phone numbers, you'll need to look at the string you got from calling browser.DocumentText for substrings that match the pattern of a URL, email address or phone number. The Regex class is what you might want to look at, since that is *really* helpful at doing pattern matching.
Good Luck!
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
i want to make something like windows simulation question ??????
if any one have any idea about creating this, Please reply quickly
many thanks
omer
|
|
|
|
|
What do you want to do exactly?
And we all try to do our best, you cannot ask, please reply quickly.
|
|
|
|
|
Your question makes no sense.
What does 'windows simulation question' mean?
Paul Marfleet
|
|
|
|
|
Maybe he wants to simulate questions asked by Windows?? Not sure which ones! Would you like to save before closing maybe?
Paul
|
|
|
|
|
I think that even we answered quickly and now we have to wait for him...
What are we simulating here? The lounge discussion board? :->
|
|
|
|
|
So sorry for being late
i have a problem with internet connection
i want to make some thing like simulation questions in the microsoft certicates
thanks so much and sorry for being late
Best wishes
omer
|
|
|
|
|
Your question still makes no sense. What do you mean by simulation questions?
|
|
|
|
|
I think I see. Are you looking to create a system which poses questions in the same way that the Microsoft exams are run? If so, you are going to need to have a database with questions and answers in them.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Sorry that my question was not understood
????
do any one know about the MCSE Questions
there are practise questions called Simulation questions????
in this type of question the student sees some thing like the actual windows interface and he can interact with it as if it is a real operating system
??????????
i want to do some thing like this
???????????
Sorry for second time
i hope it is clear now
thanks!!!!!!!!!!!!!!!
omer
|
|
|
|
|
Bitmap BMP = new Bitmap(60, 32);
Graphics g;
g = Graphics.FromImage(BMP);
g.DrawString("abcdef", font, Brushes.Red, new PointF());
MemoryStream mem = new MemoryStream();
BMP.Save(mem,ImageFormat.Bmp);
Byte[] B = mem.ToArray();
size of B should be 60*32/8
but i got the size is 7734
can i get exact size pls
|
|
|
|
|
JABIR E wrote: size of B should be 60*32/8
No, it shouldn't. It should be 54+60*4*32, which it is.
Each pixel uses four bytes, not a single bit.
The bmp file format is not a raw data file, it is an image file format that has a header (in this case 54 bytes), followed by the image data.
---
single minded; short sighted; long gone;
|
|
|
|
|
So i have this method, that accepts data inputs of various types from a web form...now some of them (if not all) can be left empty...and thus insert nothing. now my coding is not allowing it to accept these empty strings, any ideas?
This is the coding i am using at the moment;
protected void Submit_OnClick(object sender, EventArgs e)<br />
{<br />
try<br />
{<br />
vesselLicense.InsertVslLic1(Convert.ToDateTime(txtRegistrationDate.Text), Convert.ToInt32(txtMartimeRegistrationNumber.Text), txtVesselName.Text, <br />
Convert.ToInt32(ddlVesselCategory.SelectedValue),rblOperativeStatus.SelectedValue, Convert.ToInt32(ddlBasePort.SelectedValue), <br />
txtRemarks.Text, txtPreviousAuthorisation.Text, Convert.ToDouble(txtOverallLenght.Text),Convert.ToDouble(txtWidth.Text), <br />
Convert.ToDouble(txtHeight.Text), txtConstructionPlace.Text, txtCountry.Text, Convert.ToInt32(txtContructionYear.Text), txtShipyard.Text, <br />
txtHullMaterial.Text,txtStructuralRemarks.Text);<br />
<br />
lblMessage.Text = "Data Input Successful";<br />
<br />
Response.Redirect("VesselLicense_Page2.aspx", false);<br />
}<br />
catch (Exception ex)<br />
{<br />
lblMessage.Text = ex.Message;<br />
}
This is the InsertVslLic1() Method used to input the data in the database (SQL Server 200)
public void InsertVslLic1(DateTime regDate, int martimeRegNo, string vesselName, int vesselCategory, string operativeStatus, int basePort, string vesselRemarks,<br />
string previousAuthorisation, double lenght, double width, double height, string constructionPlace, string country, int constructionYear, string shipyard, string hullMaterial,<br />
string structuralRemarks)<br />
{<br />
try<br />
{<br />
DBConnection db = new DBConnection();<br />
db.OpenConnection();<br />
<br />
string _sqlString = ("EXECUTE spA_FSH_InsertVslLic1 @RegistrationDate = '" + regDate<br />
+ "', @MartimeRegNum ='" + martimeRegNo<br />
+ "', @FishingVesselName ='" + vesselName<br />
+ "', @FishingVesselType ='" + vesselCategory<br />
+ "', @OperationalStatus ='" + operativeStatus<br />
+ "', @FishingVesselBasePort ='" + basePort<br />
+ "', @FishingVesselRemarks ='" + vesselRemarks<br />
+ "', @PreviousAuthorisation ='" + previousAuthorisation<br />
+ "', @FishingVesselLenght ='" + lenght<br />
+ "', @FishingVesselWidth ='" + width<br />
+ "', @FishingVesselHeight ='" + height<br />
+ "', @ConstructionPlace ='" + constructionPlace<br />
+ "', @ConstructionCountry ='" + country<br />
+ "', @ConstructionYear ='" + constructionYear<br />
+ "', @ConstructionShipyard ='" + shipyard<br />
+ "', @ConstructionHullMaterial ='" + hullMaterial<br />
+ "', @ConstructionRemarks ='" + structuralRemarks<br />
+ "', @HomePortID ='" + basePort+ "'");<br />
db.RunSQLQuery(_sqlString);<br />
}<br />
catch (Exception ex)<br />
{<br />
throw ex;<br />
}
Any ideas on how i can fix this? thank you
|
|
|
|
|
|