|
What is it that you are trying to accomplish?
The array you are declaring is a multi-dimensional array all right, but what you are doing is saying that you have an array of 7 x 50 (rows x columns).
From your other response, you said you were trying to remember only 7 numbers. This would be a single dimensional array of 1 x 7 and you would declare it like private int[] m7Array = new int[7] . You would then access it like m7Array[2] = 25 , to set the third position to the number 25. (Arrays in C# are zero-based, so the first position is at index 0.)
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
At first I thought he was creating a jagged array of 50 * 50 * 50 * 50 * 50 * 50 * 50 ints, but I think the 7 * 50 thing is correct. But why would he get an exception trying to create 350 int s?
Cheers,
Vıkram.
Déjà moo - The feeling that you've seen this bull before.
Join the CP group at NationStates. Password: byalmightybob
|
|
|
|
|
I don't know why he would get that exception. As you said in your other post[^], he is creating an array of 7 dimensions, each of length 50. Since an int occupies 4 bytes, he is asking for 4 * 50 ^ 7 bytes.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I originally thought it was a 7-D array, but your first post made me think it was 2-D. Now I'm confused. If it's a 7-D array he's creating, I'm not surprised it bombed.
Cheers,
Vıkram.
Déjà moo - The feeling that you've seen this bull before.
Join the CP group at NationStates. Password: byalmightybob
|
|
|
|
|
Yes, his original code was creating a 7-D array. I thought what he was after was a 2-D array.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Hi,
if you want to remember a reasonnable number of combinations (i.e. less than a few
million), this is what I suggest:
- define a string format that holds the entire combination in a unified way (meaning
same combination will result in same string); example: order the numbers in
ascending order, concatenate them with a comma as separator (e.g. "1,2,5,9,12,13,14")
- use a Hashtable to store the combinations and their multiplicity: use the above
string as the key, and put the multiplicity as the value.
- now to add a combination, look it up in the Hashtable; if it is not there, add it
with multiplicity 1; if it is there, read its multiplicity (cast to an int !), add 1,
and write it back.
Thats all there is to it. No need for gigabytes of memory.
|
|
|
|
|
I am trying to use the menustrip as a tabcontrol, so the whole form changes depending on what I choose in the menu. Do I need to design one form for each menu option or is there an easier way?
Thank you for any ideas.
//Husker47
|
|
|
|
|
Create your "tab" forms (the one displayed in response to the menu choice) as a user control instead of a form. On your main form (the one with the menu) put a panel (set to Dock.Fill or the specific size you need) that will hold the user control. On the menu event handlers, create a new instance of the appropriate user control, clear your panel's controls array and add the new user control to the panel.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Or, similarly, not that I've tried it... have a Panel for each layout, and set each to .Visible=false except the one you want to display.
|
|
|
|
|
Yes, that would work as well. The benefit to having them as separate user controls is mostly that it makes it easier to design and maintain.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Thank you both for your answers, I think I'll go with the second option.
|
|
|
|
|
Hello,
Can anybody provide me some C# code samples that can extract email address of any given website. It's urgent. Thanks.
jahed
|
|
|
|
|
This sounds suspiciously like you are fishing for email addresses as part of a mass-mailing (spam) campaign. There aren't many other reasons to scrape a web site for email addresses.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Hi All;
I'm working on a simple desktop application that does the following:
1 - Reads in an Excel spreadsheet into a DataGridView as follows:
try
{
string strConnectionString = "";
if (header)
{
strConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + strFilePath + ";Jet OLEDB:Engine Type=5;" +
"Extended Properties=\"Excel 8.0;HDR=Yes\"";
}
else
{
strConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + strFilePath + ";Jet OLEDB:Engine Type=5;" +
"Extended Properties=\"Excel 8.0;HDR=No\"";
}
OleDbConnection cnCSV = new OleDbConnection(strConnectionString);
cnCSV.Open();
OleDbCommand cmdSelect = new OleDbCommand(@"SELECT * FROM [Sheet1$]", cnCSV);
OleDbDataAdapter daCSV = new OleDbDataAdapter();
daCSV.SelectCommand = cmdSelect;
dtCSV = new DataTable("Batch");
daCSV.Fill(dtCSV);
cnCSV.Close();
daCSV = null;
return dtCSV;
}
2 - allows the user to add columns, delete columns, and re-order columns. (I dont update the underlying datatable as if they add a column, it is unbound. But not sure if this is correct)
3 - I then parse through the grid verifying the values in the cells match a specified length, type, etc.
4 - output the grid values to a csv file.
Everything is pretty much working except for parsing the values, and outputing the csv. After the columns are re-ordered, it seems like they retain their original index. So when I parse through like this:
for (int r = 0; r <= dgvMain.Rows.Count - 2; r++)
{
for (int c = 0; c <= dgvMain.Columns.Count; c++)
{
value = dgvMain.Rows[r].Cells[c].Value.ToString();
}
}
The variable value contains the value of the original cell. In otherwords, say I have 2 columns, 0 and 1. I then switch their positions, so now have 1, 0. If I parse through as above, I will still be looking at them as 0, 1, not 1, 0. Or, if I move column 10 to position 1, and read that, I wont read the value until c = 10, but I need to read it when c = 1. What I need to do is to reset the indexes of the columns to be in the order that they are displayed. Has anyone done anything like this before?
|
|
|
|
|
Got a solution if anyone is interested:
In order to do this, you will need to call the GetFirstColumn method on
the Columns collection, as this method will take display order into account
(while the iterator will not). You need to follow that up with a call to
GetNextColumn using the previous column. This makes it perfect for an
iterator:
private static IEnumerable<datagridviewcolumn>GetDisplayOrderEnumeration(DataGridViewColumnCollection columns)
{
// Get the first column.
DataGridViewColumn column = columns.GetFirstColumn(DataGridViewElementStates.None);
// Continue while there is a column.
while (column != null)
{
// Yield the column.
yield return column;
// Get the next column.
column = columns.GetNextColumn(column,DataGridViewElementStates.None, DataGridViewElementStates.None);
}
}
The yield keyword will help create an IEnumerable implementation which
you can use a foreach statement to cycle though. You can use it to get the
name of the column to get the value of from the row:
for (int r = 0; r <= dgvMain.Rows.Count - 2; r++)
{
foreach (DataGridViewColumn c in GetDisplayOrderEnumeration(dgvMain.Columns))
{
value = dgvMain.Rows[r].Cells[c.Name].Value.ToString();
}
}
The method I gave you will give you an enumeration you can cycle through
to get the rows in the display order, which you can then use to access the
values in the same order in the underlying data source.
Thanks to Nicholas over at the msdn forums.
|
|
|
|
|
hi all,
I am USING WINDOWS, C#.Net(2.0)
all i need is, my client is asking me to put a Update Preferences feature where is which i need to check for update software(which is on server) and the checking preferences or
either daily or weekly or monthly
please suggest me how to fulfil this task...
i will be happy if u can provide how to update also(i don't want using ClickOnce--coz its not supporting my windows project)
thnx in advance
prashanth
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Beyond the obvious user interface considerations that allow the user to configure the schedule interval, you need to store that preference somewhere. If you want something that is automatic (similar to Windows Update), you will need to write a Windows Service that is responsible for checking to see if an update is available, downloading it, and (optionally) installing it.
This service needs to know about the schedule settings and set some sort of a timer based "wakeup" event to occur x amount of time from today, where x is your schedule interval.
Another option would be to create a separate executable that you then schedule through the Windows Scheduled Tasks interface, but I'm not sure how easy/difficult it is to programatically do that.
As far as downloading the update, you will need to provide either an HTTP or FTP location to host the updated file (or files) and then the client will need to access that location and download the file. You can look at this article for a URL based file downloader:
http://www.codeproject.com/useritems/filedownloader.asp[^]
If the server hosting the update is guaranteed to always be local, you could also do this using file shares and copy the file over the network. Keep in mind that this is the least scalable approach.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Hi!
I m building a windows application in visual studio.net 2003....i want to display my data in the format like we can display in table control of asp.net web application.
Basically i want to read one row from database and display it like its first column in first row of control,second column in second row of control and so on alongwith their column names as its heading.
Can u help me in this context or can u give me the control name in which i can access its particular cell like we can in table of asp. i tried datagrid but first problem is that its displays one row of database in row format and secondly i can't format its one cell acc to my requirement like making that cell's text bold etc.
Thanx
|
|
|
|
|
I'm not an expert on Winforms, but once you have a DataSet, shouldn't you be able to manipulate it the way you want?
EEmaan wrote: secondly i can't format its one cell acc to my requirement like making that cell's text bold etc
Have you checked out a DataGrid's events?
Cheers,
Vıkram.
Déjà moo - The feeling that you've seen this bull before.
Join the CP group at NationStates. Password: byalmightybob
|
|
|
|
|
hi i am gonna create msi and give it to client
i want to track the installation date(when clients installs my application i need to catch that date PROGRAMATICALLY Now--before i handover to clinet)so that i can give customized check for software update daily/weekly/monthly
hope u got my question
help me plz
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
One possible approach is to write a custom action in the installer that encrypts a string version of the date/time and writes it to the registry. Since it is running in the installer, you will capture the date (and approximate time) when the client installed the software. Making it encrypted (and possibly using a non-human-readable registry key name, like a guid) and storing it is a binary registry value will help prevent someone from tampering with the value.
You can then read the value from the registry, decrypt it, and do any date comparisons you need.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
can anyone tell me the error inthis chat code.I think it was donein .net2003 and i converted it to 2005.but"PageModule" causes the error.
if ( TB_ToSend.Text.Length > 0)
{
PageModule.Chat.AddMessage(sChannel,
sUser,
TB_ToSend.Text);
Rhydo
|
|
|
|
|
what is PageModule ? What is the error ?
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 all,
i'm having troubles in selecting a specific node in a treeview after selecting it from a datagridview
i.e. i want to select from the tree by selecting in the datagridview
thanx alot
|
|
|
|
|
plz tell me the directive of clsdataclass
I got a code for disscussion forum in .net2003.
when i converted it to 2005.Error"missing directive for clsDtaClass"
Rhydo
|
|
|
|