|
you can always create an XmlDocument object and load up the settings file and make the changes manually. For web applications I know there's a way to change the config file but I'm not sure if it will work in your case. Here's how I did it for my web application:
<br />
Configuration config = ConfigurationManager.OpenExeConfiguration(""); <br />
ConfigurationSection section = config.Sections["connectionStrings"];<br />
<br />
<br />
config.Save();<br />
and that's it
|
|
|
|
|
Thanks for the reply, but that isn't really what I'm looking for. I'm familiar with web configs and the configuration manager. My problem relates to C# class libraries. They don't allow the settings file to be modified at runtime and my typed datasets use the application settings file to determine the connection string.
I would like to dynamically set the connection string property based on the application environment at runtime.
Cheers.
|
|
|
|
|
need to control the band of net (ethernet) plate, to control "UPLOAD" and "DOWNLOAD". It would like to know if somebody already made something similar. Debtor
|
|
|
|
|
Hiiii everyone.
I have a problem with datagrids and queries.
I'm making a program where the user specify the columns he would like to view in the datagrid.When the program runs for the first time and the user type his columns(ex. all of them in the table) it's ok. but when choosing other columns,the non-chosen columns' values are set to null but not disappeared from the datagrid.
I want them to be disappeared and only the selected columns are shown, how can I do this??
Thanks for ur answer .
Calma
|
|
|
|
|
Hi,
I want to khnow the Key codes of both "Enter" buttens one is at alphabetside and other is numpad side. Also I didn't find the key code/name of properties key and all num pad keys i.e /,*,-,+,.,enter is remaining. Please tell me Key.NAMES or Key codes of that.
Thanks
Syed Shahid Hussain
|
|
|
|
|
Syed Shahid Hussain wrote: I want to khnow the Key codes
They hide that information in the documentation[^]
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
Keys key = e.KeyCode;
Debug.WriteLine(String.Format("KEY: {0}", key));
}
led mike
|
|
|
|
|
Except that the documentation/code you provided doesn't give all of what he asked for. The two enter keys have the same value in that enumeration.
I wrote a keyboard interrupt handler back in the dos days, the hardware itself returns different scancodes. The Win32 KeyboardHookStruct contains a scancode member, so if you're using keyboard hooking you might be able to get different values from that.
Hooking is not somehting I'd recomend for a beginner programmer to attempt however.
|
|
|
|
|
dan neely wrote: The two enter keys have the same value in that enumeration.
if it is true then how i can find out key code. (not an expert programmer) Can u help me further. Please.
thanks
Syed Shahid Hussain
|
|
|
|
|
Don't cross post.
Without hooking the keyboard driver and getting the scan code, there is no way your code will ever be able to tell the difference. Your normal C# code never gets the scan codes, it gets virtual key codes, which are in the Keys enumeration.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You can find working hooking examples from google. Just be careful not to have any unsaved data in other apps. If you mess something up in the example and leave the standard windows key handlers disconnected you'll have to reboot and forceclose all your other apps.
|
|
|
|
|
Hello Shahid
I know this reply came quite late, but here is a sample code for keyboard hooking. I didn't study it yet -I'm still stuck in my exams-, but I copied it from an earlier post for later revision. Maybe you can make your way through it:
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace GlobalKeyHook
{
public class KeyboardHook : IDisposable
{
#region Hook-dlls
[DllImport("user32", EntryPoint = "SetWindowsHookExA")]
private static extern int SetWindowsHookEx(int idHook, KeyBoardCatcherDelegate lpfn, int hmod, int dwThreadId);
[DllImport("user32.dll", CharSet = CharSet.Auto,
ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
private static extern short GetKeyState(int keyCode);
[DllImport("user32", EntryPoint = "MapVirtualKey")]
private static extern int MapVirtualKey(int wCode, int wMapType);
[DllImport("user32", EntryPoint = "CallNextHookEx")]
private static extern int CallNextHook(int hHook, int ncode, int wParam, KeybHookStruct lParam);
private const int
WH_KEYBOARD = 2,
WH_KEYBOARD_LL = 13;
[DllImport("user32", EntryPoint = "UnhookWindowsHookEx")]
private static extern int UnhookWindowsHookEx(int hHook);
#endregion
private bool m_DisableHooking = false;
public bool DisableHooking
{
get { return m_DisableHooking; }
set { m_DisableHooking = value; }
}
public KeyboardHook()
{
kbcatcher = new KeyBoardCatcherDelegate(KeyBoardCatcher);
keybhook = SetWindowsHookEx(WH_KEYBOARD_LL, kbcatcher,
Marshal.GetHINSTANCE(typeof(KeyboardHook).Module).ToInt32(), 0);
if (keybhook == 0)
throw new ExternalException("Error: " + Marshal.GetLastWin32Error().ToString() + "\r\nCould not hook keyboard");
}
public KeyboardHook(bool AddModifierData)
: this()
{
this.AddModifierData = AddModifierData;
}
#region Dispose
private readonly int keybhook;
private bool disposed;
public void Dispose()
{
if (!disposed)
{
UnhookWindowsHookEx(keybhook);
GC.SuppressFinalize(this);
disposed = true;
}
}
~KeyboardHook()
{
Dispose();
}
#endregion
private struct KeybHookStruct
{
public int vkCode, scanCode, flags, time, dwExtraInfo;
}
private delegate int KeyBoardCatcherDelegate(int code, int wparam, ref KeybHookStruct lparam);
public static bool CheckKeyPressed(params Keys[] keys)
{
for (int i = 0; i < keys.Length; i++)
if (!CheckKeyPressed(ref keys[i])) return false;
return true;
}
public static bool CheckKeyPressed(ref Keys key)
{
return CheckKeyPressed((int)key);
}
public static bool CheckKeyPressed(int vkey)
{
short ks = GetKeyState(vkey);
Console.WriteLine(ks);
return ks == 1;
}
public bool IsKeyPressed(Keys key)
{
return CheckKeyPressed(ref key);
}
public bool AreKeysPressed(params Keys[] keys)
{
return CheckKeyPressed(keys);
}
private const int HC_ACTION = 0;
[MarshalAs(UnmanagedType.FunctionPtr)]
private KeyBoardCatcherDelegate kbcatcher;
public event KeyEventHandler
KeyDown = null,
KeyUp = null;
private const int
wpKeyDown = 256,
wpKeyUp = 257;
public bool AddModifierData = true;
public readonly Keys[] Modifiers = { Keys.Alt, Keys.Control, Keys.Shift };
private int KeyBoardCatcher(int hookcode, int wparam, ref KeybHookStruct lparam)
{
if (HC_ACTION == hookcode)
{
if ((wparam == wpKeyDown && KeyDown != null)
|| (wparam == wpKeyUp && KeyUp != null))
{
try
{
Keys k = (Keys)lparam.vkCode;
if (AddModifierData)
k |= Control.ModifierKeys;
KeyEventArgs e = new KeyEventArgs(k);
if (wparam == wpKeyDown)
KeyDown(this, e);
else
KeyUp(this, e);
if (e.Handled) return 1;
}
catch { }
}
}
return CallNextHook(keybhook, hookcode, wparam, lparam);
}
}
}
Regards
|
|
|
|
|
Thanks Brother, I'll check it.
God Bless You with Success in your exams.
Allah Hafiz
Syed Shahid Hussain
|
|
|
|
|
Greeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeat (that is not exactly I want but it'll help me a lot. Thanks Indeed)
Thanks
Now I'll Check it and inform u later.
Syed Shahid Hussain
|
|
|
|
|
you should Google it
it can be done using directx > direct input
how ever i didnt did that
It is Good to be Important but!
it is more Important to be Good
|
|
|
|
|
how to use the datalist in c# code?
i need an example to know haw can i use it to show data from database
thanks..
-- modified at 0:18 Saturday 14th October, 2006
with changing controls inside it and give every conrol a datafield from a table
Mohsen
|
|
|
|
|
Hello
Here is a sample code quoted from MSDN:
<pre><%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>
<html>
<script runat="server">
ICollection CreateDataSource()
{
// Create sample data for the DataList control.
DataTable dt = new DataTable();
DataRow dr;
// Define the columns of the table.
dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue", typeof(String)));
dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));
dt.Columns.Add(new DataColumn("ImageValue", typeof(String)));
// Populate the table with sample values.
for (int i = 0; i < 9; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Description for item " + i.ToString();
dr[2] = 1.23 * (i + 1);
dr[3] = "Image" + i.ToString() + ".jpg";
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}
void Page_Load(Object sender, EventArgs e)
{
// Load sample data only once, when the page is first loaded.
if (!IsPostBack)
{
ItemsList.DataSource = CreateDataSource();
ItemsList.DataBind();
}
}
</script>
<body>
<form runat=server>
<h3>DataList Example</h3>
<asp:DataList id="ItemsList"
BorderColor="black"
CellPadding="5"
CellSpacing="5"
RepeatDirection="Vertical"
RepeatLayout="Table"
RepeatColumns="3"
ShowBorder="True"
runat="server">
<HeaderStyle BackColor="#aaaadd">
</HeaderStyle>
<AlternatingItemStyle BackColor="Gainsboro">
</AlternatingItemStyle>
<HeaderTemplate>
List of items
</HeaderTemplate>
<ItemTemplate>
Description: <br>
<%# DataBinder.Eval(Container.DataItem, "StringValue") %>
<br>
Price: <%# DataBinder.Eval(Container.DataItem, "CurrencyValue", "{0:c}") %>
<br>
<asp:Image id="ProductImage"
ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ImageValue") %>'
runat="server"/>
</ItemTemplate>
</asp:DataList>
</form>
</body>
</html></pre>
For more details, you could write DataList in your MSDN index.
Regards
|
|
|
|
|
Hi all !
ImPACT have used DICOM to transfer the images obtained at CT scanner assessments to our lap top PC. These images are then analysed for the standard ImPACT image quality parameters .
images in size are about 0.5 mb .
I want to write a app for the PC that supports DICOM storage service class as a service class provider wiht C#.net .
I needs some info About this .
Any help would be greatly appreciated
s_mostafa_h
|
|
|
|
|
i have 4 forms Form1.cs,Form2.cs,form3.cs,form4.cs
form1 contains an object of form2,form4
form2 has object of form3
form4 has object of form3
i have generated
mod1.netmodule of form2 and form3
and
mod2.netmodule of form3 and form4
now i want to generate exe i am using this command
csc /t:exe /out:c:\myexe.exe c:\Form1.cs /addmodule:mod1.netmodule /addmodule:mod2.netmodule
i get the error CS0101:the namespace already contains defination of form 3
sir i have to generate the above two modules in the same manner as i told(it is must to go through this way) tell me how to handle error
one option that i think is to modify the .netmodule at run time if this type of error comes
plz tell me some solution of this problem
|
|
|
|
|
Hi all
How can i access a specified field in 'Crystal Report' by code
eg : for example how can i increase a value of a specified field of Crystal Report by code
thanks
SalehMahmoud
|
|
|
|
|
I have created a db in SQL server with C# code (local).
I want to use this db on another computer, at local level.
It generates an error. I think the problem resides on the username and password.
¿Could anyone explain me (with c# code) how can I use this db in different local computers?
Saludos, Giovanni
|
|
|
|
|
Simply modify the connection string to point to the remote computer's name (or IPAddress), instead of (local). For example, if your connection string is now
"Persist Security Info=True;Integrated Security=false;Initial Catalog=Database;User ID=sa;Pwd=;Data Source=(local);" just change it to
"Persist Security Info=True;Integrated Security=false;Initial Catalog=Database;User ID=sa;Pwd=;Data Source=YourRemoteMachineName;"
|
|
|
|
|
Something that I have to say is: Both computers are not connected via network.
Then, the database is transported manually to another computer. I tried to access de data of that database, but it generates an error ("ERROR: Cannot open database "estebansho" requested by the login. The login failed. Login failed for user 'GIOMOVIL\Giovanni'.")
GIOMOVIL is the name of the equipment where I tried to open the db.
Giovanni is the username of the equipment where I tried to open the db.
PLEASE, HELP ME.
Saludos, Giovanni
|
|
|
|
|
|
Hi,
I have a dialog box that has a AxWebBrowser in it. I need to synchronize an edit in my dialog with a specific edit in the web page that I display (when the user type ssomething in the web page I need the dialog edit box to show the text as well).
IHTMLDocument2 has a bunch of methods that look like they would help (onkeydown, onkeyup etc) but I can't figure out how to hook them up with my dialog edit box.
Does anybody have any suggestions?
thanx
|
|
|
|
|
Hi,
If several items in one ListBox1 are selected and would like to be moved to listBox2 then how is this done please?
Obviously these items should be removed from listBox1
Somethink like:
for each(item in listBox1.row)
listbox2.items.add(item)
Could you correct this please?
Thank
|
|
|
|