|
Hello,
Is there any way to work around the .Net bug that doesn't allow text in a combobox to be highlighted with the mouse? This seems like something that any combobox should allow.
Thanks,
Blake
|
|
|
|
|
It depends on the ComboBox.DropDownStyle style. If you're using ComboBoxStyle.DropDown , you can select and enter new text. If you use ComboBoxStyle.DropDownList then only the list items in that ComboBox can be select and, hence, there is no need to highlight certain text. This behavior is defined by the Combo Box Common Control which the .NET ComboBox class encapsulates, hence the behavior is the same for native Combo Box controls in Win32 applications. This is not a bug.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Actually, you can't select the text even if you are using DropDown instead of DropDownList. You can edit the text and enter new text, but you can't highlight the text with the mouse like you normally can in an edit box. You can use shift and the arrow keys to highlight text, but holding down the mouse button and moving the mouse will not work. I've read on the internet that this is a bug.
Does any one know of any combobox controls on the internet that might fix this bug, or would the only way to get around it be capturing the mouse events and trying to do it on my own?
Thanks,
Blake
|
|
|
|
|
Works in .NET 1.1, but I did notice it doesn't work in .NET 1.0. Never noticed that. If you can, upgrade your code base to 1.1. It does contain enhancements and bug fixes (like for this bug! ) after all. If not, you could implement this using the mouse events or overriding WndProc in a derived class and handling the notification messages, though doing all that should be exposed through mouse events and managed methods already (at least in this case). Note that creating such a work around will probably break the correct behavior when run under .NET 1.1.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
Let's say that I created a DLL of managed code in VB.NET and wanted to use that in my C# project. What code would allow me to "import" the code from the file for use in my C# projects?
Thanks in advance!
Happy Programming!
WWW::CodeProject::BNEACETP
|
|
|
|
|
All managed code written from a language which targets the CLR compiles to Intermediate Languages, or IL. Assemblies are language-independent. Just add a reference to this managed assembly in your C# project, just like you reference System.* assemblies (almost all written in C#) in VB.NET. As far as assemblies are concerned, the source language in which they were written does not matter (although some languages support more features of Microsoft IL (MSIL) than others).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for the help!
Happy Programming!
WWW::CodeProject::BNEACETP
|
|
|
|
|
In your opinion, what's the best language to develop .NET applications ??
Free your mind...
|
|
|
|
|
IMO, C#. It was, after all, written from the ground-up for the .NET Framework and supports almost every feature of MSIL based on what I've read in the ECMA standard for the Common Language Infrastructure (CLI). It also offers a syntax similar to many powerful languages like C++, Java, and Perl which makes learning and knowing other languages easier.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks.
Free your mind...
|
|
|
|
|
All is in the title:
I want to store and return references to objects.
How can I do that?
Thanks
|
|
|
|
|
Foo(ref object oMyObj)
Bar MyBar = new Bar();
Foo(ref MyBar)
|
|
|
|
|
Why are you ref'ing an object? It's already a reference type. This is really only necessary for value types.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Typing to fast and doing to many things at once
Haste makes waste I guess
|
|
|
|
|
Because it's not the same kind of reference...? A ref parameter behaves like a reference in C++ - you can modify what it refers to.
static void Foo(ref string str) {
str = "Yo";
}
static void Main(string[] args)
{
string s = null;
Foo(ref s);
Console.WriteLine(s);
}
--
<british-accent>Pass the jam, would you?
|
|
|
|
|
Yeah but I misread the original question. He wanted to store and retrieve not pass the object to a method.
|
|
|
|
|
Yeah I saw that later in Heath's response. Anyhow, Heath was generalizing a bit too much on references. They are handy at times just as out .
--
<british-accent>Pass the jam, would you?
|
|
|
|
|
For strings, yes, because they are immutable and handled a little differently. I agree that ref and out are handy even in managed code (they are often necessary when P/Invoking native methods, sometimes even with reference types (like for pointer pointers)), but in the case discussed here they are not.
Keep in mind, though, that objects do not require this - only value types and strings (guess I should'be mentioned that too, but at the time I didn't think about it). Take this little example:
using System;
public class Test
{
public static void Main()
{
string s = string.Empty;
Console.WriteLine(s);
Foo(s);
Console.WriteLine(s);
Test t = new Test();
Console.WriteLine(t.s);
Foo(t);
Console.WriteLine(t.s);
}
private static void Foo(string s)
{
s = "Testing";
}
private static void Foo(Test t)
{
t.s = "Testing";
}
public string s;
public Test()
{
s = "This is a test";
}
} The output would be:
This is a test
Testing
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I see what you mean. Basically you're just creating a handle (the "reference"), in this case Test. Bear in mind that I do COM on a daily basis. [out] is God.
--
Try walking in my shoes. You stumble in my footsteps.
|
|
|
|
|
Properties and fields, a basic element of objects:
public class MyClass
{
private object o1;
private object o2;
public MyClass()
{
}
public object O1
{
get { return this.o1; }
set { this.o1 = value; }
}
public object O2
{
get { return this.o2; }
set { this.o2 = value; }
}
} Can you use fields instead if they are public, but properties are recommended because you can check the value before assigning them to your private fields ("store").
You should read the topics discussed in the .NET Framework SDK as well as vast collection of articles here on CodeProject for examples.
If you're talking about serialization, see http://msdn.microsoft.com/library/en-us/cpguide/html/cpovrserializingobjects.asp[^]. This gives an overview of serialiation as well as advanced topics and many examples using binary and SOAP serialization, as well as the more basic XML Serialization (which doesn't handle everything that true serialization, but is good to use in many cases such as storing configuration options and application state. There are several articles here on CodeProject that discuss those. Just do a search for serialiation.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I am trying to develop a program for the PocketPC in C#. It requires the use of cdmapi which only is available in the SDK as cemapi.h and cemapi.lib for C++. I really don't want to do this in C++.
How can I use/access/import/convert/??? the available library for use in C#.
Thank in advance for the advice
camasmartin
hobby programmer
|
|
|
|
|
You'll have to P/Invoke all the functions and redefine the structs and interfaces, as well as the constants/enumerations required for the functions and interface methods.
I'm not on my machine with the WinCE SDK, but since the CEMAPI exposes COM interface, it might also use a typelib. In this case, you can use tlbimp.exe to import a typelib as a COM interop assembly (RCW).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
This is what I would like to do:
1. Read in a WAV file
2. Break it up into segments of 256 samples each, with an overlap of 64 samples.
3. Refer to each segment as Segment[i] where "i" is the number of samples.
I'm done with steps 1 and 2. This is the code block that I used to segment the samples:
// *** CODE FOLLOWS ***
// For the WAV file I'm working with, there are 17 such segments
for(int i = 0; i < 17; i++)
{
for(int j = 0; j < 256; j++) {
WaveSegment[i,j] = objWaveToSegment.Data[(i*64) + j];
}
}
/// *** END OF CODE ***
In the above snippet, objWaveToSegment is an object of another class that reads in the WAV file and provides access to it's data.
Now, how do I create 17 1*256 arrays called "Segment" such that when I refer to Segment[1] I get samples 0..255, Segment[2] is 64..319 etc.
Thank you for your replies in advance 
|
|
|
|
|
Probably a too simple answer but I suppose this would do the job
public WaveSegment[] GetWaveSegment(int index){
WaveSegment[] ws=new WaveSegment[256];
for (int arrIdx=0;arrIdx,256;arrIdx++0{
ws[arrIdx]=WaveSegment[index,arrIdx];
}
return ws;
}
Maybe you could also investigate the Array.Copy static method
|
|
|
|