|
Hi Sakthi,
you should not directly manipulate controls from outside their container (form);
also making Controls static is not recommended.
instead give you form some public methods and/or properties that manipulate
the controls, and use these methods/properties to get a state or set a new state.
Regards,
|
|
|
|
|
I just got into school for Computer Information Systems, and I am currently in my first programming class (ROOKIE!!!)
I got bored with the assignments they were giving me so I decided to start my own project. However I am running into a problem.
I created a StreamReader() in order to read a .txt file and distribute the contents into a [250,4] array. Now I've got all of that working, but the array is not completely filled. There is more to be added during the execution of the program.
Now to the point. I am needing to search the first column of the array for a spacific value, and have it return the subscript so that I can access the value of the 4th column at that subscript. Now the only method that I have been shown for this is BinarySearch(); but for this to work the array must be in ascending order. Come to find out the Array.Sort() method only works on one-dimentional arrays... So how would I accomplish sorting the multidimentional array so that I keep all of the information in it's appropriate 'row'? Or if I can't sort it, is there another method that might serve the same purpose?
Any help would be greatly appreciated! (Please keep it reletively simple, I'm still gettin' familiar with the terminology)
Eric
|
|
|
|
|
Eric (eD) wrote: Now the only method that I have been shown for this is BinarySearch(); but for this to work the array must be in ascending order.
You don't need to use a method for searching. Just loop throught the items and look for the value.
If the rows in the array have different meaning, perhaps you shouldn't use an array at all, but an object oriented solution like a list of objects. If you want to locate the items by a specific value, you can use a dictionary of objects. Example:
Dictionary<int, Person> persons = new Dictionary<int, Person>;<br />
persons.Add(7, new Person("Paul", "Simon"));<br />
persons.Add(42, new Person("Art", "Garfunkel"));<br />
Person art = persons[42];
---
single minded; short sighted; long gone;
|
|
|
|
|
Didn't know that was possible with dictionaries, that's cool!
I would probably create a custom class (like you did with Person) and use ArrayList or something similar.
I would only use old-school multi-dim arrays if performance was a real issue.
But with 250x4 I don't think it can be
g'luck
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
First off, Thanks for your responses!
From what I understand, the above looks like it would work. The problem is, I don't know where to start...? (I'm a complete rookie at this) Does anyone know where I can find some sort of instructional for dictionaries? or possibly just a breakdown of the above example?
Thanks again.
|
|
|
|
|
I have already created the tables in access.I want to get the create table queries of the existing table.
Plz help me
|
|
|
|
|
jesusara wrote: I want to get the create table queries of the existing table.
This makes no sense. What do you want ? Can't you write the queries you need ? Is that the problem, you don't know SQL at all ?
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 )
|
|
|
|
|
Hello,
well this is not exactly what u must be wanting. Coz this actually doesnot make sense.
do u mean to say, u need to get the table names or table columns of a particular table that you have already created in access?
Keshav Kamat
India
|
|
|
|
|
dear;
how can i make my next button run my next windows application form.
thank you
ahmad al-omar
|
|
|
|
|
The best way is to write your forms as user controls and switch between them, if you want a wizard type interface. I think .NET 2.0 has a wizard control you can use, also. Otherwise, you just get an event handler for the button, and show the new form.
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 )
|
|
|
|
|
Hi Ahmad,
you can use an object of the form to show.
Create a new button in the first form. Label it as next.
double click the button. In the sub section that appears, place the following code.
//I am assuming that the second form name is Form2. Use accordingly.
Form2 fm2 = new Form2(); <br />
fm2.Show();
this.Hide();
I hope this helps
Keshav Kamat
India
|
|
|
|
|
thank you
i tried it and it works good .
ahmad al-omar
|
|
|
|
|
Search for Pizza Hut here in the forum to find an article dealing with that "although it deals with it in a tricky way"
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
I need to link or call a exe file(form) if i click the button.How is thw method or coding.Please help me i'm in thouble now.TQ very much
private void button1_Click(object sender, EventArgs e)
{
???????
}
The exe file name is connection....Tq
|
|
|
|
|
You're looking for the Process[^] class.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I need to change a Cell Value in a DataGridView which gets its data from DataBase, the problem is the type of the data I need to change is int16 in SQL and I need to change it in the dataview to string example:
if (this.dataGridView1.Rows[0].Cells[1].Value.ToString() == "0")/// its type is int16
{
/////////////////////// I need to change it from 0 to "Exist"
this.dataGridView1.Rows[1].Cells[2].Value = Int16.Parse("Exists", null);/// throw an exception
this.dataGridView1.Rows[0].Cells[2].Value =5 ; /// this works as I give it int , but this is not what I need :S
}
Thanks,
Nena
|
|
|
|
|
DataGridView just displays information, am I right? Can't you just directly edit the Value of a cell?
|
|
|
|
|
Hi Sean,
my main problem is that the column I need to edit its value is Short in the DataBase.
Therefore each type I pass string to this Column an Expection is throw Input is not in the correct form, That's way i was trying to convert string to int16 but still I can't do it.
This is so annoying to me , I don't want to change the field in the DataBase all I need is to change the Display instead of "0" to a string "Exists".
Hope i made it clear this time.
Thanks a lot
Nena
Egypt
|
|
|
|
|
Hi nena,
I hope this helps.
string Value;
string Exists="Exists";
Value= Datagrid1.Rows[1].Cells[1].Value.ToString();
if (Value=="0")
Datagrid1.Rows[1].Cells[1].Value = Exists;
be careful of the cell that you are working on. But it should work.
You can use a for loop for the rows and the columns. If you are searching in both rows and and columns for the value 0 then use something like this.
string Value;
string Exists="Exists";
for(int i=0; i<LoggerDatagrid.Columns.Count; i++)
{
for(int j=0;j<LoggerDatagrid.Rows.Count;j++)
{
Value= Datagrid1.Rows[j].Cells[i].Value.ToString();
if (Value=="0")
Datagrid1.Rows[j].Cells[i].Value = Exists;
}
}
hope it works.
Keshav Kamat
India
|
|
|
|
|
Hi Keshav,
This works only if the original data given to the DataGrid was string , my main problem is that the column I need to edit its value is Short in the DataBase.
Therefore each type I pass string to this Column an Expection is throw Input is not in the correct form, That's way i was trying to convert string to int16 but still I can't do it.
This is so annoying to me , I don't want to change the field in the DataBase all I need is to change the Display instead of "0" to a string "Exists".
Hope i made it clear this time. Waiting for your help
Thanks a lot
Nena
Egypt
|
|
|
|
|
I can't really shake a solution out of my sleeve, but I know a workaround that I often use.
Somewhere in your application you are probably using a Stored Procedure, or a SQL Query.
SELECT * FROM table
you could change it to this
<br />
(SELECT [Name], 'Exists' <br />
FROM [Table]<br />
WHERE [Field] = 0)<br />
<br />
UNION<br />
<br />
(SELECT [Name], [Field]<br />
FROM [Table]<br />
WHERE [Field] <> 0)<br />
Another option would be to add a new column to your dgv, and place it in place of the other one, and populate it with the desired values.
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
Int16 Value;
string Exists="Exists";
for(int i=0; i<LoggerDatagrid.Columns.Count; i++)
{
for(int j=0;j<LoggerDatagrid.Rows.Count;j++)
{
Value= (Int16)Datagrid1.Rows[j].Cells[i].Value.ToString();
if (Value=='0')
Datagrid1.Rows[j].Cells[i].Value = Exists;
}
}
please check if this works.
Keshav Kamat
India
|
|
|
|
|
Hello !
Can You tell me, what add-ins are you using, and what they do ?
Add-in's to Visual studio 2005
-- modified at 2:50 Wednesday 21st March, 2007
One nation - underground
|
|
|
|
|
Add-In's to what?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|