|
Goutam Patra wrote: I have checked your code but it works in Windows 7 also!
are you sure you are able to see Network Drive as well as Local Drive by using OP codes.
|
|
|
|
|
|
Try using WMI instead. The following code should get a list of network drives:
public static List<string> FindNetworkDrives()
{
List<string> networkDrives = new List<string>();
SelectQuery query = new SelectQuery("select name from win32_logicaldisk where drivetype=4");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementObject obj in searcher.Get())
{
networkDrives.Add(obj["Name"]);
}
return networkDrives;
}
|
|
|
|
|
Hi Pete O'Hanlon,
I did try your code, but unfortunately still no results.
|
|
|
|
|
My guess would be you have a problem with permissions on your Win7 machine; nothing wrong with all the code you tried.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I think also it had to do with permissions, but dont understand how,
i tried to get files via asp.net fileupload control from those network drives, no problems...but when i try to read the same file with StreamReader im getting again that error.
|
|
|
|
|
Uhhh, what? How does a web app fit into all this?? There's something you're not telling us that's affecting this problem or causing it.
|
|
|
|
|
Priya Prk wrote: but in windows7 i can only see the local drives.
1. Create a sample class/project console application that ONLY does this code and prints the results via System.Console.
2. Open a console window in Windows 7.
3. Run that app.
4. If it does NOT display the network drives then remove the condition check and run again.
Post that class, the complete class, and the output if it does not report the drives.
If it does report the drives then it means the context of your original app, not the code, is the source of your problem.
|
|
|
|
|
Hello everybody,
i have a problem with my treeview. In my event I check the selected TreeNode with the function TreeView.GetNodeAt(MousePosition).
I also want to know the number of the selected node in my TreeView. For example I have three nodes in my TreeView and I Selected the second one - how can i get this information?
Do I have to compare the selected node with the existing one in my TreeView?
Regards
|
|
|
|
|
Presumably winforms - belongs in the winforms forum.
IIRC there is an index property which is the index within the parents node collection.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The FindNode[^] method may be what you are looking for, but I may have misunderstood your question.
I must get a clever new signature for 2011.
|
|
|
|
|
S0784 wrote: For example I have three nodes in my TreeView and I Selected the second one - how can i get this information?
In treeview a node has lots of property which Information would you want to get.
treeView1.SelectedNode.Index.ToString();
treeView1.SelectedNode.Name;
treeView1.SelectedNode.Nodes.Count;
treeView1.SelectedNode.Level.ToString()
I have mentioned about someone property of treeview.
in case of any query let us know.
|
|
|
|
|
The SelectedNode property helped me a lot.
Thanks for your help.
|
|
|
|
|
Hello Everyone
Im generating two columns of dataGridView from database on click event button. The first column is FoodName, second column is FoodType.
On my dataGridView I have set it a click event so the user can enter a number on particular cell of the third column like so...
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 2)
{
string cellContent = "0";
if (this.dataGridView1[e.ColumnIndex, e.RowIndex].Value != null)
{
cellContent = this.dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString();
}
using (InputBox ib = new InputBox("Enter new stock amount:", this.dataGridView1[0, e.RowIndex].Value.ToString(), cellContent))
{
if (ib.ShowDialog() == DialogResult.OK)
{
this.dataGridView1[e.ColumnIndex, e.RowIndex].Value = ib.Result;
cellContent = ib.Result;
this.dataGridView1.Controls.Find("btn" + cellValue, true); "THIS IS THE LINE WHERE I WANT TO GET THAT cellFoodTypeValue...
}
}
}
}
How can I get the FoodType value from that row?
Here is the code of my click event button...
(Hence: ColFoodQtyStock and ColFoodStatus are template columns generated at run-time)
private DataGridViewTextBoxColumn ColFoodQtyStock = new DataGridViewTextBoxColumn();
private DataGridViewTextBoxColumn ColFoodStatus = new DataGridViewTextBoxColumn();
private void cmdStarters_Click(object sender, EventArgs e)
{
OleDbConnectionStringBuilder connBuilder = new OleDbConnectionStringBuilder();
connBuilder.DataSource = @"C:\Users\AP_AE\Desktop\DTPOS_APP\DataBase\DtposMenu.accdb";
connBuilder.Provider = "Microsoft.ACE.OLEDB.12.0";
connBuilder.Add("Jet OLEDB:Engine Type", "5");
string foodTypeSql = @"SELECT FoodName, FoodType FROM Food WHERE FoodType = @foodType";
using (OleDbConnection conn = new OleDbConnection(connBuilder.ConnectionString))
{
dataGridView1.Columns.Clear();
dataGridView1.RowTemplate.Height = 60;
dataGridView1.Visible = true;
dataGridView2.Visible = false;
try
{
OleDbCommand foodsCommand = new OleDbCommand(foodTypeSql, conn);
OleDbParameter foodType = foodsCommand.Parameters.Add("@foodType", OleDbType.VarChar, 15);
OleDbDataAdapter foodsDa = new OleDbDataAdapter(foodsCommand);
DataSet ds = new DataSet();
conn.Open();
foodType.Value = "Starter";
foodsDa.Fill(ds, "Food_table");
ds.Tables["Food_table"].Columns.Add(new DataColumn("Quantity In Stock", System.Type.GetType("System.Int32")));
ds.Tables["Food_table"].Columns.Add(new DataColumn("Status", System.Type.GetType("System.String")));
for (int i = 0; i < ds.Tables["Food_table"].Rows.Count; i++)
{
ds.Tables["Food_table"].Rows[i]["Quantity In Stock"] = 0;
ds.Tables["Food_table"].Rows[i]["Status"] = "<Always On Stock>";
}
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "Food_table";
DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
dataGridViewCellStyle1.Font = new Font("Verdana", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dataGridView1.Columns[0].Width = 420;
this.dataGridView1.Columns[1].Width = 180;
this.dataGridView1.Columns[2].Width = 300;
this.dataGridView1.Columns[3].Width = 308;
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
}
}
}
Any help please would be very greatfull
Thanks in advance
Lapeci
|
|
|
|
|
Something like this?
Obviously you change the column numbers to those required.
|
|
|
|
|
|
Hi,
something is wrong in the C# forum right now, so this message will not show as is, until things get fixed, and you won't be able to react either, you could however start a new thread if necessary.
My reply is rather simple: inside the ContentClicked handler, you know the row and column index of the cell you clicked; and you can access the Rows, Columns, and Cells arrays using integer indices. So you probably want
value=dataGridView1.Rows[e.RowIndex].Cells[the_index_of_the_column_you_want];
You may need a .Value at the end. Hope this helps.
|
|
|
|
|
Please ignore the above reply, there has been a cockup in the c# forum.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
OK, the forum is alive again, so here we go:
IMO it is rather simple: inside the ContentClicked handler, you know the row and column index of the cell you clicked; and you can access the Rows, Columns, and Cells arrays using integer indices. So you probably want
value=dataGridView1.Rows[e.RowIndex].Cells[the_index_of_the_column_you_want].Value;
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Whats the most efficient way of storing and referecing a list of ~2000 unsorted key value pairs in C#?
I understand that there is not really any definite answer here since it will depend on the data, however, I'm not familiar enough with the .NET framework to know which ones to even test. I'm an MFC C++ developer who is migrating to C#. In MFC C++ I would use a CMap or a muiltidimensional array to store the data and it would be efficient enough for my needs. I'm finding in C#, neither (a series of arrays or a Hashtable) is working out very well. Both seem to be far less efficient than my implementations in C++ but I'm assuming this is mostly because of my inability to code C# as well as I do in C++.
For reference, I need to store 5-6 values for ~2000 keys (3-30 character strings) and receive between 200-10,000 updates a second (averaging about 750) total.
Recomendations? Should I look at another data storage method or should I work on improving my existing attempts?
|
|
|
|
|
I think a Dictionary should be fine. For most of the operations, execution time it proportional to number of elements in it (O(1)).
|
|
|
|
|
if you want to remember only one value (the most recent one) for each key you encounter, then yes a Dictionary is what you want, and
myDictionary[myKey]=myValue;
is all it takes.
Dictionaries are hashed; they are built on top of arrays, which when running out of their capacity are copied to larger ones. Therefore it may make sense to use a constructor overload that takes an initial capacity parameter.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Interested in what kind of 'performance' you are seeing and if you are running these tests in debug or release and if you are timing this in the IDE or not.
I have seen some interesting differences in speed and performance between these configurations before but when doing a test in a full production build outside the IDE they have ended up as very close to a wash. Also you may want to look at allocating new additions to the collections in groups rather than single records at a time. I have also seen that help performance wise.
|
|
|
|
|
Like others said, Dictionary<>() is a good bet. However, I wouldn't recommend using 3 - 30 character strings as the key. Performance will be better if you use something lighter like an int or something. You really haven't given us enough information to make a more informed design.
|
|
|
|
|
WTF?
This is not what I typed, and I can vote on it.
I can't delete or edit it.
Whats is wrong with this?
Also the other Answers do not appear to relate to the Question.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|