|
I would like to add a CountChanged event to the standard ListBox control. Is it possible to access the properties of a standard MS control in this way and if so could it be done runtime or would I need to create a custom control? I have a basic understanding of the event raising and handling protocol but I'm scratching my head on how to link the property. Any pointers gratefully received.
|
|
|
|
|
If you use VB2010 (also Express Version)you can extend or change standard methods – and I guess it's the same with controls – by using 'Extension Methods'. If you google for that, you'll find plenty of information and sample code. In VB the Extension Methods have to be defined in a module, not a class.
|
|
|
|
|
|
Thanks for the suggestions guys but neither really fits the bill. I could possibly write extension methods for all the possible ways that the number of items in a List Box and set off an event in each one but that seems rather cumbersome and subject to possible errors. Extender Provider adds properties to controls but I don't need another property, I need to monitor an existing one.
The intention is to have an event trigger every time that the count of list items changes for any reason. Such an event could be used to warn when a list of attendees becomes oversubscribed, for example. Now clearly it is possible to monitor the ListBox.Count property using a timer, for example, which probably is more than good enough for nearly all uses. I just wondered whether it was possible to raise an event directly. Guess the answer's, not.
|
|
|
|
|
Member 9082365 wrote: The intention is to have an event trigger every time that the count of list
items changes for any reason
Actually, this is a piss-poor idea. A ListBox control should not be the "authoritative" collection of items, such as your list of attendees. A dedicated collection should be the one that controls this and either raises its own event or throws an exception of the collection is considered full. The ListBox should be used as it was designed, as a visual representation of the backing collection, nothing more.
Your idea is not quite as simple as creating your own version of ListBox with this little functionality added. The ListBox Items collection is a seperate class, called ObjectCollection I believe. You'd have to inherit from ObjectCollection, add your CountChanged event to it, the create your own ListBox implementation, changing out the Items collection with one that uses your new ObjectCollection implementation, handle the ObjectCollection.CountChanged event you made, and, finally, the ListBox would have to expose it's own CountChanged event that fires whenever the underlying ObjectCollection.CountChanged event was raised.
...or some variant thereof. But, the basic concept doesn't change from this.
|
|
|
|
|
Well thanks for the lecture. It was only an off-the-top-of-my head example (I don't know what the initial enquirer has in mind) but feel free to belittle us all. We so love it.
As for the actual information, it is much as I suspected. Something I'll maybe take on when I've a few spare days (or weeks!)
|
|
|
|
|
I used something similar for a listview. If you still need a solution i can dig for it and post some snippets here... i guess that the listbox doesn't work that much different.
The thing gave me also a few long hours to search for a solution...
|
|
|
|
|
Am in the middle of developing a window app when i got stuck.the tools used are as follows combobox,numericbox,textbox and a radio button.Actually what i wanted to achieve is small inventory.Meaning that whenever i click on the value in the combobox as against that of numericbox it will automatically subtract from stored values.
Pls help me out tanks
|
|
|
|
|
Quote: Am in the middle of developing a window app when i got stuck
could you be a bit more specific?
perhaps show a bit of code to where you get stuck or witch error you hang on.
|
|
|
|
|
samfrancis wrote: it will automatically subtract from stored
Okay so go right ahead, you have my permission. Please come back and ask questions when you get stuck.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
It would be somewhat like this:
Private Sub myCombo_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) _
Handles myCombo.SelectedIndexChanged
Me.myNumeric.Value += CDbl(myCombo.SelectedIndex) ' add index value
End Sub
|
|
|
|
|
hai guys..
i am having trouble with vb.net..please anybody tell me that how to copy a file to system directory. while i'm tried to copy using the command "file.copy", it is says "you need administrative privilage to access system directory"..
thanx in advance
|
|
|
|
|
info4shajeer wrote: you need administrative privilage to access system directory
If you do not have an administrator account then you cannot do it. If you do have an administrator account then modify your program's properties to run as administrator, as described here[^].
|
|
|
|
|
|
I have a cpp code, I had difficulty in doing the conversion to visual basic 6, is there anything that can help me. The following sample cpp program is:
// Defined to disable deprecated functions warning in Visual C++ 2005
#define _CRT_SECURE_NO_DEPRECATE 1
#include <windows.h>
#include <stdio.h>
#pragma pack(1) // set byte packing
typedef struct {
unsigned __int32 bLength;
char szSerNum[9];
char szProdName[9];
unsigned __int64 MinFreq;
unsigned __int64 MaxFreq;
struct {
unsigned __int32 ExtRef:1;
unsigned __int32 FMWEnabled:1;
unsigned __int32 Reserved:30;
} Features;
} RADIO_INFO2;
#pragma pack() // set back the default packing
// G305 API function type declarations
typedef int (__stdcall *FNCOpenRadioDevice)(int iDeviceNum);
typedef BOOL (__stdcall *FNCCloseRadioDevice)(int hRadio);
typedef BOOL (__stdcall *FNCGetInfo)(int hRadio,RADIO_INFO2 *info);
typedef BOOL (__stdcall *FNCSetAtten)(int hRadio, BOOL fAtten);
typedef BOOL (__stdcall *FNCSetPower)(int hRadio, BOOL fPower);
typedef BOOL (__stdcall *FNCSetAGC)(int hRadio, int iAGC);
typedef BOOL (__stdcall *FNCBlockScan)(int hRadio,DWORD *Freqs,size_t Count,int StopSquelchRaw,DWORD FeedbackTime,HWND WinHandle,DWORD Msg);
typedef BOOL (__stdcall *FNCStopBlockScan)(int hRadio);
typedef BOOL (__stdcall *FNCCodecStart)(int hRadio,void (__stdcall *CallbackFunc)(void *),void *CallbackTarget);
typedef BOOL (__stdcall *FNCCodecStop)(int hRadio);
int main(int argc, char* argv[])
{
// load the G3 API library
HMODULE dll=LoadLibrary("wrg305api.dll");
if (!dll) {
puts("WRG305API.DLL not found !");
return 0;
}
// link G3 API functions
FNCOpenRadioDevice OpenRadioDevice=(FNCOpenRadioDevice)GetProcAddress(dll,"OpenRadioDevice");
FNCCloseRadioDevice CloseRadioDevice=(FNCCloseRadioDevice)GetProcAddress(dll,"CloseRadioDevice");
FNCGetInfo GetInfo=(FNCGetInfo)GetProcAddress(dll,"GetInfo");
FNCSetAtten SetAtten=(FNCSetAtten)GetProcAddress(dll,"SetAtten");
FNCSetPower SetPower=(FNCSetPower)GetProcAddress(dll,"SetPower");
FNCSetAGC SetAGC=(FNCSetAGC)GetProcAddress(dll,"SetAGC");
FNCBlockScan BlockScan=(FNCBlockScan)GetProcAddress(dll,"BlockScan");
FNCStopBlockScan StopBlockScan=(FNCStopBlockScan)GetProcAddress(dll,"StopBlockScan");
FNCCodecStart CodecStart=(FNCCodecStart)GetProcAddress(dll,"CodecStart");
FNCCodecStop CodecStop=(FNCCodecStop)GetProcAddress(dll,"CodecStop");
if (!GetInfo || !BlockScan || !StopBlockScan) {
puts("Not all needed API function not found. Please update the WR-G305 software!");
FreeLibrary(dll);
return 0;
}
// open the first available radio
int hRadio=OpenRadioDevice(0);
if (!hRadio) {
puts("No G305 device could be opened !");
FreeLibrary(dll);
return 0;
}
// obtain the radio info to be able to detect USB connected receivers
RADIO_INFO2 radio_info;
radio_info.bLength=sizeof(radio_info);
GetInfo(hRadio,&radio_info);
// check for USB receiver
BOOL USB_recv=FALSE;
if (!memcmp(radio_info.szProdName,"G3USBv",6)) {
puts("USB receiver detected");
USB_recv=TRUE;
}
// set Power,AGC and Attenuator
if (SetPower(hRadio,TRUE)) puts("The device is turned ON");
else puts("The device failed to turn ON");
if (SetAtten(hRadio,FALSE)) puts("The attenuator is OFF");
else puts("The attenuator failed to turn OFF");
if (SetAGC(hRadio,3)) puts("The AGC is FAST");
else puts("The AGC failed to switch");
// for USB receivers codec streaming must be started
if (USB_recv) CodecStart(hRadio,NULL,NULL);
// prepare the buffer for the blockscan from 600 to 800 kHz
size_t i;
DWORD Freqs[101]; // buffer for frequencies to scan
for (i=0;i<=100;i++) Freqs[i]=(DWORD)(88000000+200000*i);
// let's start the blockscan with 1001 frequencies, don't stop by Squelch.
// no feedback (after a million ms), don't send us the buffers, we'll check that all
if (BlockScan(hRadio,Freqs,101,256,1000000,NULL,0)) puts("The block scanning started..");
else puts("The block scanning failed to start");
puts("Scanned data:");
for (i=0;i<=100;i++) {
while (Freqs[i]>255) Sleep(10); // the frequency is not scanned yet, we have to wait
//printf("Freqsss: %ld\tRAW:%ld\n",88000000+200000*i,Freqs[i]);
printf("Freqsss: %ld\tRAW:%ld\n",Freqs[i]);
}
// the block scanning is over
if (StopBlockScan(hRadio)) puts("Block scanning is stopped");
else puts("Block scanning couldn't stop");
// for USB receivers codec streaming must be stopped
if (USB_recv) CodecStop(hRadio);
// close the device handle
if (CloseRadioDevice(hRadio)) puts("The device is closed properly");
else puts("The device failed to close");
// free the G3 API library
FreeLibrary(dll);
return 0;
}
|
|
|
|
|
i didn't see any question, you are asking us to convert for you?
|
|
|
|
|
densti wrote: I have a cpp code, I had difficulty in doing the conversion to visual basic 6, is there anything that can help me.
C++ to VB6?
VB6 has been deprecated, meaning that there's only minimal support available. Next to that, VB6 does not facilitate all that's possible in C++.
Compile your code using watcom or whatever and link to it - and stay away from VB6. There's no new technology created using that technology, since there's no place left to buy a new compiler. It "might" run on Win8 with some tweaks, but there's a good chance that the support will be cut in anything beyond Win8.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
|
Hi,
At my work, I have to test a Visual Basic application. I don't have the code source.
Often I get runtime errors. When I get one, I try to understand what is the cause before I contact the developer. Often it is a runtime error.
I want to know if a tool can give information about such errors without having access to the code source.
Any suggestions?
Thanks,
Claude
|
|
|
|
|
Hello,
Try this[] one
Nick
|
|
|
|
|
Gagnon Claude wrote: Often I get runtime errors. When I get one, I try to understand what is the cause before I contact the developer. Often it is a runtime error.
In an ideal world, you'd have a file, generated by the app in debug mode, that mentions all the steps that you took before the exception occurred. That way they have the steps to reproduce the bug.
..and it might be caused by something totally unrelated
Have you considered requesting the code? What is the app created with? In .NET we call them usually exceptions, I'd associate a "run time error" more with classic VB.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hello everyone I am a beginner to programming with vb.net. Currently I am creating a notepad like application in VB (just for learning and practice). I want to make an installer for it (by using external installation creating utilities) so that I can give it to my friends just like any standard application.
But I have just confused that how I will decide that which files should be placed in installation with the .exe file. Can any one help me, that which other files are needed to properly run the application.
Also currently I am creating the application with visual studio 2005. I don’t have much knowledge about dot net framework. So how can I decide that to someone whom I am giving my application have required dot net framework. And if they don't have than how I can give it to them.
One more thing, is their any windows version (like XP, Vista, 7 etc) related limitation to consider, in order to properly running the application. If yes then please explain it too.
Any other suggestions are appreciated.
Thanks
|
|
|
|
|
you can find it here, goodluck.
|
|
|
|
|
No friend, I already have idea about it.
What I want is to collect all the files which are required to run my application, put them in other folder, and then create a installer by using a external installer creation utility. (I don't want to use visual studio's setup and deployment wizard). (I request you to read my about post ones again). Now please give me required suggestion. Thanks for your time.
|
|
|
|
|
You should know what your app requires to run. After all, you wrote it!
But, as a general rule of thumb, from the files in the Bin\Release folder, you don't need:
*.vshost.*
*.pdb
myApplicationName.xml
Everything else, you probably need.
|
|
|
|
|