|
Hi,
if you define giveCellValue(TextBox myTextBox, ...) then it will accept any TextBox,
but it wont accept a Label.
if you define giveCellValue(Control myControl, ...) then it will accept a TextBox,
a Label, and all other Controls; now you can access myControl.Text since Text is a
property that exists for all Controls; but you still would not be able to access
a property that exists just for some Controls.
The better way however is to define giveCellValue(string text, ...)
and call it like so:
String ReadValue1 = giveCellValue(myTextBox.Text, gridMyGrid, 1, 0, 0);
String ReadValue2 = giveCellValue(myLabel.Text, gridMyGrid, 1, 0, 0);
Doing so giveCellValue does not have to touch other, independent, Controls at all.
It is better from OO perspective.
Hope this helps.
|
|
|
|
|
Hello everyone,
I am implementing a simple C# OLE DB Provider (C# COM Server). For C# (managed code), I am wondering what is the entry point (which coclass and which method), client will invoke at first?
It is clear if I write my own client, but I am confused about other clients which I do not have source codes, for example, if I use Microsoft Excel (as a client) to invoke my C# OLE DB Provider, which is the entry point? Any reference materials or debug tools?
thanks in advance,
George
|
|
|
|
|
I have to Sort An Array using C#. I have declared the Array to be 50 element size. I have got the array elements from the user using for loop. If I print the original array, the elements I entered got printed very well. I
have used the Array.Sort(arrayname) function in the Array Class to sort the elements.
After sorting, I printed the elements. All the elements got printed as Zero. Can any one tell What may be the problem?
The code is:
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
int num_ele;
int[] num = new int[50];
Console.WriteLine("Enter the Num of elements in the Array");
num_ele = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i
|
|
|
|
|
Hi,
that is how it looks if you test it with:
- no more thsn 25 numbers, all positive
- more than 25 numbers, all positive, of which several are zero
try it again with negative numbers !
The problem is you have a fixed array size of 50; if you enter fewer numbers, Array.Sort
will still sort those 50 numbers (the ones you did not enter all are zero).
Now listing the sorted array will include the extra zero elements, and if they happen to
be the smaller numbers, they come out first.
Furthermore your program will fail if the user asks for more than 50 numbers.
When entering the 51th number you will get an IndexOutOfRangeException.
This is how you can fix both problems:
- dont use an array, use another kind of collection (such as ArrayList, or List<int> )
- these classes automatically adapt themselves to the number of elements
- and they provide the same Sort facility
May I suggest you read a chapter on collections, then try to use them to your
advantage.
|
|
|
|
|
Could u Please tell me any tutorial about how to use Collection Classes?
|
|
|
|
|
in the declaration, you (implicitely) initialised the array with 50 zeroes, Now, for instance, if the user inputs ten positive numbers, then the Sort method will move the reamaining 40 zeroes into the leading positions of the array, putting the user's entries in the last 10 ones (if you output the whole array then you see the mistake).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi,
I forgot to mention there is another overload of Sort() that accepts boundary information,
so that can solve your immediate problem; it still leaves you with the 50 limit:
public static void Sort (
Array array,
int index,
int length
)
in your case that would be: Array.Sort(num, 0, num_ele);
For general information on either .NET or C# I would recommend you buy at least one
book and work your way through it. You could also read what MSDN has to say about
ArrayList class for instance.
|
|
|
|
|
I am using System.Reflection.Emit to create a dynamic assembly. I use ModuleBuilder.DefineType() to add a class type. I want to add a base interface e.g. "ICalculator" to my class definition but unfortunately i cannot figure out how to do this dynamically. The class constructor doesn't have any parameters. The "Interfaces" namespace has the "ICalculator" interface.
The class generated should be like this:
using Interfaces;
namespace ConcreteLibrary
{
public class ConcreteCalculator : ICalculator
{
public ConcreteCalculator()
{
}
#region ICalculator Members
public object Calculate()
{
// do nothing;
return null;
}
#endregion
}
}
How do I include the "Interfaces" namespace and the "ICalculator" interface to the "ConcreteCalculator" class? Your help would be very much appreciated.
Thank you in advance!
|
|
|
|
|
|
please disregard this inquiry. the problem is solved
|
|
|
|
|
hi all
I Wount to add DataGrid To my Mobil Application With this propertis
1- columns type combobox
2- columns type CheckBox
3- Columns type Buttun To delete the row selected by click to this button in grid this button is in evry row
thanks All
Thaer (T.h)
Thaer
|
|
|
|
|
When running the code below on a win 2003 server i receive all the 4 columns in the csv file, when doing it on xp I only get one column !?!?! how weird is that on a scale !? ...somebody run into this ?
string strImportPath = "C:\\inetpub\\wwwroot\\TempUpload\\";
string strConn = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + strImportPath.Trim() + ";Extensions=csv,txt;Persist Security Info=False";
OdbcConnection myConnection = new OdbcConnection(strConn);
myConnection.Open();
OdbcDataAdapter myAdapter = new OdbcDataAdapter("select * FROM Manufacturers.txt", myConnection);
DataSet ds = new DataSet();
try
{
myAdapter.Fill(ds,"fungus");
}
catch(Exception ex)
{
string messages = ex.Message.ToString();
}
dataGrid1.DataSource = ds.DefaultViewManager;
dataGrid1.DataMember="fungus";
myConnection.Close();
peirre
|
|
|
|
|
Haven't worked with MS Text Driver or any csv data but first thing that comes to mind is:
Make sure Regional settings are compatible with your .txt files. Maybe your list separator is not the same in both OS.
|
|
|
|
|
hi...
I am using the following code:
OurApp.LIB.TestData TestD = new OurApp.LIB.TestData();<br />
TestD.LoadData(2,Convert.ToString(lvTestA.SelectedItems[0].SubItems[0].Text.Trim()));
now this is all in the:
private void lvTestA_SelectedIndexChanged(object sender, EventArgs e)<br />
{<br />
If you click on a item in the listview (the first time) it works fine.
Once you click on another item in the listview it comes up with the error...
"InvalidArgument = Value of '0' is not valid for 'index'. Parameter name: index"
why could this be?
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
never mind.... i just put in a if(lvTestA.selecteditems.count > 0)
{
and now it works fine...
It seems that the item isnt really selected as soon as you click it... (it is cleared and then selected ???)
Thank you anyway
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Hi,
I guess there are two changed events, one when the original selection gets unselected,
the second one when the newly clicked item gets selected.
BTW do all items have subitems ?
|
|
|
|
|
yes all items have subitems
Thanks...
i thought that there are two events taking place in the SelectedIndexChange event just after i posted the message...
Thank you for your time
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Support123 wrote: Convert.ToString(lvTestA.SelectedItems[0].SubItems[0].Text.Trim())
See all that - I'd separate that out into lots of lines as it makes it much easier to debug. This is the only code that appears to use indexes so I'm guessing it is here that the problem lies.
selectedItems = lvTestA.SelectedItems;
firstItem = selectedItems[0];
subItems = firstItem.SubItems;
firstSubItem = subItems[0];
string theText = firstSubItem.Text;
string theTrimmedText = theText.Trim();
string convertedText = Convert.ToString(theTrimmedText);
TestD.LoadData(2,convertedText);
NOTE: I've left out the class names for most of the above - you'll have to fill that in.
The above code can now be much more easily debugged and stepped through. You can then see exactly which line has the problem - And you can watch the values so you can see exactly what it is doing.
This should help you narrow down your problem.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Hi,
I guess there are two changed events, one when the original selection gets unselected,
the second one when the newly clicked item gets selected.
Thaer
|
|
|
|
|
Please, tell me that Luc and you are twins and you allways think the same.
Otherwise it would look like you copied Luc's suggestion![^]
Hmm, just compared you two Birthday dates and I have to say it's a big gap in between.
Sorry Luc, don't want to say that you are soo old!
All the best,
Martin
|
|
|
|
|
Then why did you ?
|
|
|
|
|
Hmmmm,
I just wanted to show the community how well experienced you are!
All the best,
Martin
|
|
|
|
|
I m trying to make an application which is connected with more than one database and its depend on user that user may have any name so I create a database name is blank in bin --> debug folder when user make a new colony database. It copy from the existing database which have already same tables query etc.
plz give me coding.
plz help me and thakx in advance
Nikesh Yadav,
CSS infotech,
Gurgaon,
Haryana(India).
|
|
|
|
|
Er nikesh yadav wrote: plz give me coding
The code will be highly dependent on the database that you use.
If it is Access then a simple file copy might suffice
If it is SQL Server the two choices I'd look at would be to restore a blank database to the location that you want, or to have a set of scripts to create a brand new database
Other database system may offer similar choices, they may offer something completely different.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|