|
Hi,
I am beginer in C#. I have an array and ComboBox that are define in Form1.Now I want to use this objects in a Usercontrol that open by preesing a bottun in form1.People say I should use property,but I don't know how I should write and use propert.
I wouls appreciate if somebody give me an example of define and useing of Propetie.
regards
|
|
|
|
|
|
I read some article,but I couldnot find any sample.
please give me some samples.
thanks
|
|
|
|
|
i doubt it, i clicked the first result and it had heaps of examples.
|
|
|
|
|
That's right,but I could not get y answer.
Look. I have a main form that there is 3 buttons and 1 combobox.
in this main form i declare an array that keeps the name of my menu after pressing the related key.
string[] Name_Menues = new string[10];
When I press the first button, a usercontrol apprear and I write the below code to fill the combobox.
Name_Menues[0] = "Input_Passengers";
Cmb_Box.Items.Add(Name_Menues[0]);
Cmb_Box.SelectedItem = Name_Menues[0];
Uc_Check_In uc = new Uc_Check_In();
pnl_Main.Controls.Add(uc);
uc.BringToFront();
uc.Dock = DockStyle.Fill;
The usercontrol appers,after pressing the button .Now I want to clear the contest in combobox in main form when press another key in usercontrol.
|
|
|
|
|
Hello,
My suggestions are:
Use the dynamic "System.Collection.Specialized.StringCollection" instead of fix string[].
For filling the ComboBox with values of you field, you should use a loop.
Hold the instance of your UserControl as a field member of the form and only hide it (Visible = faalse) if you don't need it.
Alireza3839 wrote: The usercontrol appers,after pressing the button .Now I want to clear the contest in combobox in main form when press another key in usercontrol.
Your usercontrol should implement an event (delegate) which is called after you button was clicked.
Your form connects to this event and clears the combobox in the event handled code.
Hope it helps!
All the best,
Martin
|
|
|
|
|
Our client needs C# with SQL Server consultants immly.
Total postions 5 and rate is $50-$55/Hr DOE.
Desired exp is 5+ Yrs and it is a long term.
Location is Orange County,CA.
Intrested candidated email your resumes to navconsultantsinc@gmail.com
|
|
|
|
|
Very well!
roger wong
msn:wenmianbj@hotmail.com
|
|
|
|
|
|
Use the jobs board[^] to post any job posting. Do not spam the programming forums.
|
|
|
|
|
1. I have 2 forms, form1 and form2. form1 has a button click event, and form2 has a method called displayText(string s).
When i click the button on form1 how do i get form2 to invoke the displayText() method?
Does form2 have to be static or is there another way? Also how do i make a static form in VS2005?
2. What would be the best way to implement a console into an application? Some sort of text box and use custom methods to add text? or is there a droppable control and possibly exploit Console.Out methods.
3. What is the best way to implement user authentication where users are stored online (something like windows activation), google returns absolutely nothing when i searched for application authentication. Also any details to prevent cracking etc will be appreciated (this doesnt have to be total crack proof etc, just interested in learning).
-- modified at 23:07 Monday 11th June, 2007
|
|
|
|
|
Better buy a book For COnsole Application ie., Windows Application adn try to learn the concept and implement it.
We cannot explain it here about all the Questions You have Asked?
SO for what you tried for the Console Application and also abouit the Cross Page Post back and also about the User Authentication.
Better buy a book and start reading it and try to implement it.
Regards,
Satips.
|
|
|
|
|
Sorry i dont understand the first 3 lines of your post.
|
|
|
|
|
|
1 - if form1 holds the instance of form2, it can call a method on the form. Either way, a delegate is the nicest way to do this
2 - There's no control apart from the textbox
3 - The best way is to store user roles in a database. The issue is, if it's a windows app, people can just decompile your code and remove your authentication checks.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
1. What if i want to do the reverse, form2 calls a method in form1 when form1 holds the instance.
|
|
|
|
|
Hello,
Like Christian said before, a delegate would be the nicest way.
But you could also pass the instance from form1 to form2 (for example over the constructor).
All the best,
Martin
|
|
|
|
|
Ok thanks, never thought of that.
|
|
|
|
|
|
i don't know what to do really i've seen the code 100 times and it seem right
so if anyone can help....this's the code
public void ajout_dossier_image(string dossier,string matr)
{
if (Directory.Exists(dossier))
{ try
{
scanDirectory(dossier, "*.jpg", System.IO.SearchOption.TopDirectoryOnly);
String selectedImage = selectedImg;
if (imgList == null)
return;
foreach (String img in imgList) {ajout_image_seul(img, matr);}
}
catch (Exception exe) { MessageBox.Show("erreur du dossier de l'image");}
}
}
public void ajout_image_seul(string nom_img,string matr)
{
try
{
string date = "01/01/2005";//Convert.ToString(DateTime.Now)
string conStr = @"Provider=Microsoft.JET.OLEDB.4.0;" + @"data source=DermatoSoft_DB.mdb";
dataGridView1.DataSource = null;
ds = new DataSet();
conn = new OleDbConnection(conStr);
command = conn.CreateCommand();
conn.Open();
command.CommandText = "INSERT INTO Image (Numero_Patients,Nom_Image,Date_Image,"
+"Commentaire_Image) VALUES (" + matr + ",'" + nom_img + "','" + date + "','exemple commentaire')";
adapter = new OleDbDataAdapter(command);
adapter.Fill(ds);
conn.Close();
}
catch (Exception exe)
{
MessageBox.Show("erreur dans l'ajout de l'image");
}
}
thanks
|
|
|
|
|
What's happening when you run it?
If your getting an error what is it?
I think part of the problem is using the adapter.Fill method - I'm pretty sure that you need to use the Update method and also I'm not sure yoy sepcify a command text for the dataset - I thought you used an InsertCommand and calling update called the appropriate Commands with the change rows in the Dataset, and likewise the appropriate Update and Delete commands - been a while though so I could be wrong there - I'll look it up and let you know.....
|
|
|
|
|
my problem is that i used this command in other part and i'm sure that the command run
the error is that he cant make the instruction insert into
that there's an error in type
|
|
|
|
|
Well I was right in the first instance - if you look at the constructor for the OleDbDataAdapter - the command query which you pass in is for the SELECT command ONLY - so it's not going to take care of what you are trying to achieve here - you need to create an InsertCommand and then call update - that should fix it (maybe!)
|
|
|
|
|
i know the problem is that he don't wanna connect to the table image that i added but for the first table patient he can can connect this thing gonna make me crazy
so please can you tell me why csharp can access to an access table and not another and the two are in the same file
so please help
|
|
|
|
|
Thats's not the problem as far as I can see - sorry I'm struggling a bit with your english to understand what you are saying, but I think your issue is that the connection is fine - it's what you are trying to do with it is wrong. You can't use an INSERT (SQL) statement as a SelectCommand on the adapter and you can't use the Fill method on the adapter to call the InsertCommand - you have to use the Update method instead.
Perhaps you can put up the error and maybe that might cast some more light - but it looks as though it's just an issue with using the adapter incorrectly...
|
|
|
|