|
What Dave said above should do it.
One note though - be sure to free any resources used by the RegistryKey objects - encolsing them in using statements is good:
using (RegistryKey sk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\DirectX"))
{
}
It's also good practice to check sk for null as if the key's not present on the system sk.GetValue("Version") will thrown an exception.
P.S. No need to explicitly return from a void method.
2A
|
|
|
|
|
|
i set the dataSource to datagridview
DatTbl = CustomerManger.SelectCustomersAllDT();
ds.Tables.Add(DatTbl);
DatTbl.TableName = "Customers";
dgvCustomers.DataSource = null;
dgvCustomers.DataSource = ds;
dgvCustomers.DataMember = "Customers";
then is selectionChange event i Select another data in list and before set it to listbox datasource .. datasource of datagrid change and all columns and data of customer cleared and replaced by Notices ???????
private void dgvCustomers_SelectionChanged(object sender, EventArgs e)
{
NoticList NL=NoticeManager.SelectNoticesbyCustCD(newCust.CustId);
}
if i comment this line datasource of datagrid view doesn't change
|
|
|
|
|
I don't know. You probably need to show more code.
And you don't need the DataSet, you can use the DataTable (or preferably its DefaultView) as the DataSource.
|
|
|
|
|
hi, I'm trying to get multiple values that was selected in a dropdown list, the problem is that it's only returning one value, if I select two or more values only give me one, here's the code:
List<String> dep = new List<String>();
foreach (ListItem item in sltnamedep.Items)
{
if (item.Selected)
{
dep.Add(item.Text);
}
}
for (int i = 0; i < dep.Count; i++)
Response.Write(dep[i]);
|
|
|
|
|
is the MultiSelection is enabled for the listView? can you print/check the number of selected items using sltnamedep.Items.Count property
Jibesh V P
|
|
|
|
|
Make sure you have focus on the control.
MSDN says:
Quote: Items appear selected only when the ListView control has focus. To select items in response to a user action such as a button click, be sure to call the Focus method in addition to setting this property.
|
|
|
|
|
Hi I created i project using a reference to a dll (Microsoft.Office.Core).
I'm going to port this project on different computers, and it happens that this assembly is under different path.
So to be able to use the project I need to update the reference.
Is there a way to let know the project to look for the correct path of the .dll?
|
|
|
|
|
See some of these answers[^]; this DLL comes with MS Office, so you need that installed on the target system.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi I have created a word document where user fill in details. Now i want to save those details when the user close the word document.
Thank you in advance
|
|
|
|
|
Using an UPDATE statement, to update the database. You'd use an IDbConnection to connect to the database, and use a IDbCommand to execute the SQL-statement.
Post some code if you're stuck, or get a good introductionary book if you don't know where to begin.
|
|
|
|
|
Hi,
How to read a jpeg image from the binary data in a file in C#? Here, image is stored as a bindary data in the file.Now i need to construct a image from this data.
|
|
|
|
|
Assuming that the data is a Jpeg file, just stored as binary:
byte[] bytes = File.ReadAllBytes(path);
MemoryStream ms = new MemoryStream(bytes);
Image returnImage = Image.FromStream(ms);
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
Thanks Griff..But this gives "Argument Exception" saying parameter is not valid.
|
|
|
|
|
Then I suspect that the data is not a jpeg file - what are you trying to do? Not "read a file as an Image, but what is the file? Why are you reading it? What are you trying to achieve? It may be that one of use is using the wrong terms!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
I need help on how to capture windows messages.
|
|
|
|
|
|
What technology are you using? Windows Forms or WPF? If you're using WinForms, there's an implicit WndProc that you can add your code into. If it's WPF, things get a little more complicated as you have to add your own WndProc handler.
|
|
|
|
|
Dear All,
I have used SqlConnection to connection to Sql database. There are some friends, they always use IDbConnection. He also suggest me use IDbConnection. I also see some of project here using IDbConnection: AccountPlus[^]
_ What's the difference bettwen SqlConnection and IDbConnection.
_ Using IDbConnection is better?
Tks,
LVD
|
|
|
|
|
SqlConnection implements IDbConnection and therefore IS_A IDbConnection.
In my opinion, one should code to the interfaces; that's what I do, and I'm not the only one. It may not matter now, but if you ever have to provide support for another database, you'll be glad you did.
I regularly work with SQL Server, MySQL, Oracle, Access, and Excel. In the past I've also had to work with Cache, Ingres, and maybe some others I've forgotten. As long as there's an ADO.net connector, my code can work with it.
|
|
|
|
|
To add to PIEBALDconsult's answer IDbConnection is not used in LINQ to SQL DataContext or Entity Framework.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Hi,
Totally new to LINQ and wondering how I can get the following sandbox code to work. Ideas?
List<PositionValues> list = new List<PositionValues>();
PositionValues item1 = new PositionValues();
item1.Position = 2;
item1.Value = 44;
list.Add(item1);
PositionValues item2 = new PositionValues();
item2.Position = 1;
item2.Value = 33;
list.Add(item2);
var resultList = from b in list group b by b.Position into g orderby b.Value select b;
It relies on:
public struct PositionValues
{
/// <summary>
/// The position.
/// </summary>
public int Position;
/// <summary>
/// The position.
/// </summary>
public double Value;
}
Thanks for looking,
Alan
|
|
|
|
|
It might be helpful to tell us what isnt working, or what you expect to happen.
|
|
|
|
|
Biggest thing that looks wrong to me is that your not using the groupby properly
have a look at this to for a good example 101 LINQ Samples in C#[^]
If that dont work please tell us as much information as possible and we will help you as much as we can possible.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Hi J4amieC and Simon_Whale,
Sorry I did not respond sooner. I started to look other directions and was paying less attention to this thread.
For the code supplied, I am getting the compiler error:
"The name 'b' does not exist in the current context"
If I could get rid of the error, I am hoping that the code would do two sorts:
A primary sort based on "Position" and a secondary sort on "Value". I would end up with the list grouped on "Position" and within each "Position" groupings they would be sorted based on "Value". If the following code snippet is added for a 3rd item:
PositionValues item3 = new PositionValues();
item3.Position = 1;
item3.Value = 22;
list.Add(item3);
the resulting list (I am hoping) would be ordered as follows:
resultList[0] {1, 22}
resultList[1] {1, 33}
resultList[2] {2, 44}
where the first entry in the parenthesis is the "Position" and the second is the "Value".
I had looked previously at the 101 LINQ Samples but did not see something readily that was close enough to this (but probably just missed it since new to this - good suggestion and I plan on using as reference).
Thanks again,
Alan
|
|
|
|