|
|
Thanks, it's what i used.
|
|
|
|
|
Hi,
I have another 2 questions:
1. Programming datagrid related.
I have a datagridview that displays a dataset. If I change row 1 the validation is executed. And as long as I am parked on that row the data is as I changed. But as soon as I moved to the next row the changes i have done is unchecked for that row.
I need to be able to edit multiple lines before I save the data. Do anyone know what I am doing wrong.
2. Other
Does anyone know where I can subscribe to C#/VB.Net challenges? One of my friends subscribed to a MS SQL Server site... every day they send him a problem someone struggled with (this is not beginner problems) and the following day they send the solution. This is all done to develop that ultimate experience.
Thanks in advance for your help.
Chris
|
|
|
|
|
advice: use 1 post per question, you will get more ansers.
about 1) you saw you want to edit rows, do it in sql procedures and trigger in c#.
about 2) don´t know that but when launch visual studio they ask you about some kind of experiences to participate, but look in MS site!!!!!
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Hello
I'm trying to extend a standard Windows Forms ComboBox, by adding a new property ImageMember which should display an image from database. It is supposed to be the databound property just like DisplayMember and ValueMember are.
At run-time everything works correctly. My question is how to allow one to choose a field from dataset for this property at design-time, just like you do for DisplayMember property.
The short question is: How can I make ImageMember property editor behave as DisplayMember's at design-time?
I've looked through internet and the closest solution seems to be the following:
public class ImageMemberEditor: UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
if (context != null)
return UITypeEditorEditStyle.DropDown;
return base.GetEditStyle(context);
}
public override object EditValue(ITypeDescriptorContext context,IServiceProvider provider,object value)
{
if ((provider != null) && (context.Instance != null))
{
PropertyDescriptor descriptor = TypeDescriptor.GetProperties(context.Instance)["DataSource"];
if (descriptor == null)
{
return value;
}
object dataSource = descriptor.GetValue(context.Instance);
if (this.DesignBindingPicker == null)
{
this.designBindingPicker = new DesignBindingPicker();
}
DesignBinding initialSelectedItem = new DesignBinding(dataSource, (string)value);
DesignBinding binding2 = this.designBindingPicker.Pick(context, provider, false, true, true, dataSource, string.Empty, initialSelectedItem);
if ((dataSource != null) && (binding2 != null))
{
value = binding2.DataMember;
}
value = lb.SelectedItem.ToString();
}
return value;
}
}
However, Visual Studio can not resolve designBindingPicker and DesignBinding :
"Error 5 The type or namespace name 'DesignBinding' could not be found (are you missing a using directive or an assembly reference?)"
Any help will be greately appreciated.
Thanks in advance
|
|
|
|
|
Don't cargo cult program.
Presumably the thing where you lifted your code had a "DesignBinding" that has nada to do with your control. You're simply providing a type editor, so you need to implement a method that can edit your value. How you implmement it is up to you, but you don't need to keep any of the code in the one you lifted. Just write your own code.
|
|
|
|
|
dojohansen, thanks for reply.
Looks like these classes are private to .NET framework itself and therefore can not be accessed from user code.
Anyway, all I need is an advice of how to retrieve the DataSet fields at design-time from property editor.
I'd appreciate any help on this
|
|
|
|
|
Does anyone know if its possible to select table column names in c#.
I want something like
while dtr.read()
{
combo.items.add("dtr column name");
}
|
|
|
|
|
Your question is rather incomplete.
From your code it seems you'd like to get the column names of a result set from an open data reader. Whether or not you can do that depends on the reader implementation (there's nothing in the IDataReader interface for it). Check the documentation.
In any case, why would you WANT to get it from the reader!? You should presumably know what data you're getting!?
Depending on the database you might be able to use the INFORMATION_SCHEMA built-in views:
SELECT * FROM [INFORMATION_SCHEMA].[COLUMNS] WHERE [TABLE_NAME] = 'MY_TABLE';
Or you might use a data adapter instead of the reader directly (though it uses a reader internally, so it apparently has a way of getting schema information from the reader!).
Or you might rephrase your question...
|
|
|
|
|
Hi experts,
I would ask you how I can manage the properties of my sound device by C#.
At the moment I am using winmm.dll and I am able to set the volume but I also want to check if the sound is enable or not.
Thanks,
Antonio
|
|
|
|
|
Hi all.
I am currently facing a problem using HttpWeb Request ,
I iam able to download the attachments ,but the text message i am getting is in the format http://host/share/1_.000
but how to read the text message when it comes in this format ,
The attachments are of the format http://host/share/file.doc,I am able to get the stream and construct the file .
but if i dont have any attachment and have only the text message how can i read such messages.
any help in this regaurd will be appreciated
thank you
manju
Hi..
I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++
manju
|
|
|
|
|
I have a question.
I have created a console application. It reads OPC Variable in loop.
If I started the application, it takes about 18000K of memory. If I
click at minimize button, it reduce the memory usage to 3000K.
But if I call "GC.Collect()", the memory usage will not be reduced
to 3000K. It happens only during minimizing.
If I maximize the window again, the memory usage still at 3000K-5000K.
Are there any code to reduce the memory usage without minimizing ?
Because it not happens, if I call only "GC.Collect()".
Thanks...
|
|
|
|
|
As far as i know, when you do something like GC.Collect(); your not telling the garbage collector to collect the object, your merely flagging that object for garbage collection. So when the garbage collector comes along(at a later point in time) it will collect the object you flagged.
If you post your code(specifically the loop) we might be able to get the memory usage down a bit...
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
You're not flagging anything with GC.Collect. You're just telling the GC you'd LIKE a garbage collection to occur at this time. But, it's up to the GC if it wants to do it or not. When a collection runs, your app stops while the GC walks the heap looking for objects that need to be collected.
|
|
|
|
|
I believe it's not actual memory usage that you're seeing in Task Manager - just memory that Windows has pre-allocated to your app. Any memory allocated but unused will be reclaimed if needed elsewhere or when minimized which is why you're seeing those figures.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
You may want to try GC.WaitForPendingFinalizers() as well. It's a perfomance killer and not recommended in most situations, but it could be interesting to see if it changes the memory usage you see in task manager.
|
|
|
|
|
Learn how memory work under the .NET CLR.
What you're seeing in Task Manager, which is a lousy place to look for memory usage by the way, you're seeing what memory the .NET CLR has reserved for your app. Your app may not be using all of this memory, but it's sitting in the .NET CLR Managed memory pool, waiting for your app to allocate some memory for objects or whatnot. When you minimize your app, the .NET CLR looks to see if there is any memory in the Managed Pool that isn't being used by your app and, from what it can tell, isn'tgoing to be used anytime soon. If so, this memory is taken out of the Managed Pool and returned to Windows.
Basically, you're worried about nothing. The .NET CLR is very good at managing it's memory and cooperating with Windows. If Windows needs memory back from the .NET CLR, the CLR is more than happy to scan it's pools to see what it can return to Windows.
...entirely automatically. You don't need to do anything.
|
|
|
|
|
Dave Kreskowiak wrote:
What you're seeing in Task Manager, which is a lousy place to look for memory usage by the way, you're seeing what memory the .NET CLR has reserved for your app. Your app may not be using all of this memory, but it's sitting in the .NET CLR Managed memory pool, waiting for your app to allocate some memory for objects or whatnot.
Expanding upon this; The CLR does it because asking for more memory from the kernel is an expensive operation, it's much faster to ask for a large block up front than to keep asking for little bits as needed. Also when system memory starts getting low, windows will go around asking applications if they can return extra unused memory. When this happens the same thing will occur as when you minimize the application.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
//below is my code , i want to add one entry
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration("AppDomain.CurrentDomain.BaseDirectory +"..\\..\\App.config");
// Get the count of the Application Settings.
int appStgCnt = config.AppSettings.Settings.Count;
string asName = "AppStg" + appStgCnt.ToString();
// Add an Application Setting.
config.AppSettings.Settings.Add(asName,
DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString());
// Save the configuration file.
config.Save(ConfigurationSaveMode.Modified);
// Force a reload of a changed section.
ConfigurationManager.RefreshSection("appSettings");
but instead of writing in app.config , it creates another app.config.config file, so why is it so??????
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
modified on Tuesday, September 16, 2008 5:02 AM
|
|
|
|
|
Mogaambo wrote: System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration("..\\..\\App.config");
is this path valid? Try to give full executable path or use the other overload ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel)
|
|
|
|
|
Yes it is, if i give wrong path then it gives error,
i used this way
(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\App.config")
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Check out this on MSDN[^]. It has an example doing what you want. The main page is in VB but scroll down to the community content section and someone has posted a C# translation. I've just tried it and it works.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
//I tried this code but the result is not reflecting in app.config
//WHY
// Get the configuration file.
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
// Add an entry to appSettings.
int appStgCnt = ConfigurationManager.AppSettings.Count;
string newKey = "NewKey" + appStgCnt.ToString();
string newValue = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
config.AppSettings.Settings.Add(newKey, newValue);
// Save the configuration file.
config.Save(ConfigurationSaveMode.Modified);
// Force a reload of the changed section.
ConfigurationManager.RefreshSection("appSettings");
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Sorry about that - my bad! That example uses yourexename.config if release or yourexename.vshost.exe.config if debug.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Because it's Microsoft. They provide HUGE amounts of stuff but none of it actually works properly.
|
|
|
|