|
I have a weird problem that started happening.
I have a tabcontrol with 3 tabs, and each tab has its own ListBox control.
I populate the listbox controls from a dataset i retreive from a database. Everything here is fine.
The problem comes when the data is displayed. The ListBox does contain a collection, and all the items are selectable, BUT they are invisible.
Every item in the listbox remains Invisible until I do the following:
- Move the form (by dragging with the mouse)
- Change the tab (redraws the listbox control)
Once I do that, the listbox items are viewable.
Can anyone give me any insight as to what is happening here?
Jon G
www.Gizmocoder.com
|
|
|
|
|
Can anyone suggest the easiest way to scan a photo from a c# application ... is the Windows Image Acquistion Automation Layer the way to go? or should I purchase a third party control such as what AtalaSoft, LeadTools or PegasusImaging provides? ... does anyone have any experience any of with these tools?
I need my C# app to tell any scanner to scan the current image ideally into its raw image format (so no image correction is applied) and it all needs to be from managed code.
Thanks in advance.
Rob
|
|
|
|
|
Whenever i look at the source for one all i can think of is a c++ headerfile...i.e. a prototype of a class.
what purpose do they serve?
|
|
|
|
|
well, a very good question... i'm relatively new to c# programming, too, and wondered also what they can do for me...
well, interfaces look like classes, except (see C# in a nutshell):
- the don't deliver implementations to their members, but a specification; so they are in some parts identical to abstract classes
- one class/structure can implement more than one interface, but one class can only derive from one base class
- a struct can implement an interface, but can not derive from a base class
the clue is, to define basic operations that every derived class/struct has to implement; the implementation itself may look different, but the aim of the called operations has to be the same...
let's say you implement a webshop; you know three different account types: a paypal account, a bank account and a credit card account; all types use different properties to describe the account; however, all derive from interface "IPaymentTransferAccount"
when your customer buys something from you, all have to implement a method called "GetMoneyFrom(float bucksCount, Currency currency)" - each of them has its own implementation of initializing the money transfer, but in your code, you only call "IPaymentTransferAccount account = Customer.Account; account.GetMoneyFrom(price, Currency.USD);"
finally, you need no "dummy"-implementation in a base class, but each of it can implement many other interfaces where appropriate, that's it.
hope that helps,
regards,
tajbender
|
|
|
|
|
FocusedWolf wrote:
what purpose do they serve?
An interface ensures that when something wants to invoke methods on a class implementing the interface, that those methods exist and have a particular signature. It's like a contract. If you inherit from an interface, your class is saying "I'm implementing the methods that are defined in the interface, so anyone who knows about the interface can use my methods."
Marc
MyXaml
Advanced Unit Testing
|
|
|
|
|
Wow i think i understand them now! So interfaces were made solely to make sure people deriving from a class followed the same naming conventions and provided for the same functionality in their classes?
Here's a test program i wrote that helped me out:
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
#endregion
namespace ConsoleApplication1
{
interface Wolf
{
string Fur{get; set;}
string Teeth{get; set;}
void Hunger(string food);
}
class WereWolf : Wolf
{
public WereWolf()
{
Console.Write("WereWolf mode engaged\n\n");
}
private string fur;
public string Fur
{
get { return this.fur; }
set { this.fur = value; }
}
private string teeth;
public string Teeth
{
get { return this.teeth; }
set { this.teeth = value; }
}
public void Hunger(string food)
{
string chew = food;
}
}
class RealWolf : Wolf
{
public RealWolf()
{
Console.Write("RealWolf mode engaged\n\n");
}
private string fur;
public string Fur
{
get { return this.fur; }
set { this.fur = value; }
}
private string teeth;
public string Teeth
{
get { return this.teeth; }
set { this.teeth = value; }
}
public void Hunger(string food)
{
string chew = food;
}
}
class Program : WereWolf
{
static void Main()
{
WereWolf were = new WereWolf();
Console.Write("What color is the wolf that's chewing on you? ");
were.Fur = Console.ReadLine();
Console.Write("How many teeth does it have? ");
were.Teeth = Console.ReadLine();
}
}
}
|
|
|
|
|
FocusedWolf wrote:
So interfaces were made solely to make sure people deriving from a class followed the same naming conventions and provided for the same functionality in their classes?
That's 1/2 of it. The other half is that someone that USES the interface is guaranteed that a class (which can be totally unknown) derived from the interface actually implements the methods in the interface.
In your example (and it's customary to prefix a class name with an "I" if it's an interface, so Wolf would be IWolf), your main would look more like this:
class Program
{
static void Main()
{
IWolf awolf = Factory.MakeWolf();
Console.Write("What color is the wolf that's chewing on you? ");
awolf.Fur = Console.ReadLine();
Console.Write("How many teeth does it have? ");
awolf.Teeth = Console.ReadLine();
}
Now, Factory.MakeWolf() is a static method that maybe looks at some configuration information somewhere and either returns an instance of WereWolf or RegularWolf. The point is, the Main() program doesn't care which--it assigns the instance to the interface that all specialized Wolf classes implement. It can then call methods on those instances because the interface says that they must exist.
Another reason for interfaces is that C# doesn't support multiple inheritance, but you CAN specify multiple interfaces, which is sometimes a useful way of having one specialized class that implements several different interfaces.
Marc
MyXaml
Advanced Unit Testing
|
|
|
|
|
Hello ,
I have a problem, rich text bullets are not displayed in Crystal report.
Environment : VS .NET 2003
CrystalDecisions.CrystalReports.Engine Version 9.1.5000.0 ( it came with .NET 2003 package)
CrystalDecisions.ReportSource
The problem is , I have application with rich text box, Just I cut and paste the text from wordpad , it looks like
· ABC
· CDE
· FGH
· JKL
Then I saved the TEXT into SQL server database (as a ntext format ).
Now on the crystal report , I config the database filed as a “RICHText”( from paragraph tab).
When I view the report . I am not getting the “bullets “
I checked the rich text for the above statement using Text Interpretation -à None
{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}{\f1\fnil\fcharset2 Symbol;}}
\viewkind4\uc1\pard{\pntext\f1\'B7\tab}{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'B7}}\fi-360\li360\lang1033\f0\fs21 ABC\par
{\pntext\f1\'B7\tab}CDE\par
{\pntext\f1\'B7\tab}FGH\par
{\pntext\f1\'B7\tab}JKL\par
}
can someone help me Why I am not getting the bullets and numbering in crystal report display ?
thanks
Sundar
|
|
|
|
|
Hi there!
I have a problem here and I need your help.
I have two arrays and I need to make a convolution of them.
something like that
//result = conv(a,b);
I know that in matlab I have a function to make the convolution, and in C#?!!
I need to make the convolution or is there any function that make the convolution for me?
Thank you all, Sérgio
|
|
|
|
|
you mean mathematical/statistical convolution?
u probably have to write it yourself (like most matlab functions)
there are no facts, only interpretations
|
|
|
|
|
Hi all,
I am having some image files with extensions which are not predefined in GDI+ Image library of C#.
I have tried various other libraries, but none of them are having the capability of reading my image files. My image files are in *.LL1 and *.LT1 formats.
If anyone know, how to read any fle of unknown format in C#, Plz lemme know and I truely appreciate any kind of help.
thanks in advance,
Pavan.
Pavan
|
|
|
|
|
Pavan Kumar N Tiruveedhula wrote:
how to read any fle of unknown format in C#,
That is like asking if anyone knows how to read text in an unknown language.
It looks like you are going to have to find out what the LL1 and LT1 formats are and write your own reader.
Do you want to know more?
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Hi,
yeah i indeed agree upon ur conclusion that
Colin Angus Mackay wrote:
That is like asking if anyone knows how to read text in an unknown language.
But i don't know how to write a reader program for those files and that is wht i am finding for. The only info tht i am having abt those files is header info (they call it as header info) but i don't know whether it is actually header info or not and some sample files. i have already posted it previously, but not even one reply and here it is again
IFFCL_GRAY {
bits: 12
byte: @0=0x00
byte: @1=0x00
byte: @2=0x00
byte: @3=0x00
width:[@6=ishort]/2
height:@4=ishort
start_offset:128
line_offset:width*2
datatype: lsb_msb
}
if u r havin any idea plz lemme know and i appreciate ur help,
thanks,
Pavan.
Pavan
|
|
|
|
|
Hello
I want to be able to get one record from the teacher's table and still the record in the Database. The user will enter the ID number and then press a find button. The contents of this record can be
displayed in some text boxes.
Code:
cnnTeacher.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\IBS Library System\LibrarySystem.mdb;Persist Security Info=False";
OleDbDataAdapter daTeacher = new OleDbDataAdapter("SELECT * FROM Teacher WHERE teacherID = '" + txtIDNumber.Text + "' ",cnnTeacher);
OleDbCommandBuilder cbTeacher = new OleDbCommandBuilder(daTeacher);
daTeacher.Fill(dtTeacher);
txtName.text = //code to go here for display the name of the teacher from finding ID number
Many thanks in advance
|
|
|
|
|
NEVER use concatenation for SQL commands. What do you think happens when I enter the following in your txtIDNumber TextBox ?
0' and 1 = 1; drop table Teacher-- I'll tell you what happens - you get 0wned. Your Teacher table is dropped. I could do a lot worse, too. And don't think I can't figure out what you're doing. Many people will look for simple holes like this, and with .NET and Java (or any JIT compiled language or scripting language, for that matter) it's easy because I can easily disassemble or even decompile your application. With web applications some crackers will try typical SQL inject attacks like this. If a simple crack works, believe me they'll be dropping tables, stealing credit card numbers, falsifying product orders...just about anything.
Use parameterized queries like so:
cnnTeacher.ConnectionString = @"...";
OleDbCommand cmd = cnnTeacher.CreateCommand();
cmd.CommandText = "select * from Teacher where teacherID = ?";
cmd.Parameters.Add("ID", OleDb.VarWChar, 40).Value = txtIDNumber.Text;
OleDbDataAdapter daTeacher = new OleDbDataAdapter(cmd);
daTeacher.Fill(dtTeacher); This prevents SQL injection attacks because there's a lot of checks implemented in the .NET Framework.
How do you bind data to controls? Certain not how you're doing it again. That is just assigning values, not actually binding data. To learn about data-binding, read Data Binding with Windows Forms and ADO.NET (.NET Development (General) Technical Articles)[^], any one of the samples in .NET Samples - Windows Forms: Data Binding[^], or search this site for a slew of articles on data-binding.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
|
<blink> is a remnant of Netscape and only supported by Mozilla because Netscape pays the bills. It never was a standard and according to W3C sources I've read about, it never will be.
Just view your comment in IE and see for yourself.
Besides, it's greatly overused. I once saw a professor that blinked an entire paragraph - and a long one at that - to draw attention to it (it was already red and bold). It took quite a while to actually read what it said.
And don't fret - I'm just ranting. I've hated blink ever since it was conceived and that sentiment hasn't changed since then.
BTW, I made it bold and basically flamed him because I get so tired of repeating the same ol', same ol'...about not using concatenation for SQL commands, that an unmanaged long isn't the same as a managed long , and quite a bit else. If only people searched the forum before posting, but if they could do that they probably wouldn't have quite so many problems.
|
|
|
|
|
AN UNMANAGED LONG IS A MANAGAGED INT!
/\ |_ E X E GG
|
|
|
|
|
Good - someone remembers what I say 50 times a day, it seems. Of course you visit here often. I know many don't and maybe post a couple messages to CodeProject and never return (I feel so used ). I'm thinking about writing an article with all the stuff I always say and just start directing people toward it each time I have to say it once again.
What do you think? I know Nick Parker told me I should long ago (and we're actually friends in the real workd), so I think I may.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Yeah, I remember you mentioned that Nick and you were working on one a while ago... I was pretty intersted in it. I imagine it would be quite large though.... Are you thinking of sorta a "FAQ Article"?
/\ |_ E X E GG
|
|
|
|
|
Yeah.. I know. I personally hate animated/moving stuff on pages.... But NEVER would have been a good candidate for a blink there
The problem I see with people using concatenation for SQL is that most books on SQL don't deal with issues like SQL Injection. I haven't looked at many (we have 2 or 3 T-SQL and PL/SQL references books on shelves in work) but those that I did rarely if ever mentioned the danger of SQL Injection... It's as though they see it as somthing that needs to be addressed by programming books and data access references only. It drives me insane to thnk that students throughout universities and colleges around the world are not being instructed on the simple dangers.
Regards,
Brian Dela
http://www.briandela.com IE 6 required. http://www.briandela.com/pictures Now with a pictures section http://www.briandela.com/rss/newsrss.xml RSS Feed
|
|
|
|
|
Brian Delahunty wrote:
It drives me insane to thnk that students throughout universities and colleges around the world are not being instructed on the simple dangers.
What should really drive you insane - and the reason, most often, for students not being taught what they should - is that the professors don't know! Granted, there's exceptions, especially at places like MIT, Berkely, CMU, and others, but many professors themselves don't know.
Besides, I'm a big fan of self-discovery and research. I learned far more before and during - but not in - college than I ever did at college. It takes a real interest in computer science and engineering (depending on whether your into the softer- or harder-side of computers...maybe even both) to be good and that, I believe, is what separates the good from the, well, bad.
|
|
|
|
|
I have a couple of questions regarding a System.Windows.Forms.UserControl derived control that is to be hosted in IE. Basic functionality seems to work, but I'm unable to figure out how to EnableVisualStyles...since IE is the parent application. All buttons on the control appear flat and square. Attempting to invoke the Application.EnableVisualStyles() call within my control's Load event causes IE to GPF. Attempting to host a Form within my control that contains a button with the flat style set to System still results in flat buttons.
Also, I'm not able to get keyboard hot keys to work for any buttons on the user control. The tab key works for moving focus between buttons, and the mouse key works, but if I hit alt-char to invoke the hot key...nothing.
Am I limited to creating owner draw buttons and handling keyboard events at the control level? Anyone have any experience in this area?
Thank you in advance.
Ron Ward
|
|
|
|
|
I've done quite a bit of work in this area dating way back to the .NET 1.0 beta days.
As far as hot keys, understand that only dialogs process characters and may or may not pass those messages to child controls, such as your UserControl . In the case of IE, it most likely won't because a site could hijack your settings (the web is a very dangerous place to visit, probably even more hostile than Iraq right now!). That would be my educated guess.
As far as visual styles, calling Application.EnableVisualStyles() must be done in an application - not your control. What this does is load a general manifest from the .NET Framework directory (ex: %WINDIR%\Microsoft.NET\Framework\v1.1.4322) BEFORE controls are created, which encapsulate the Windows Common Controls. Once those are loaded into an address space for a process and used by a particular module, that module cannot use two different versions (but the process can, IIRC).
You need to instead embed a manifest in your PE/COFF executable (not the assembly itself, rather, the manifest of resources) using a particular ID.
For starters, read my article Windows XP Visual Styles for Windows Forms[^], which describes the "old" way (still supported) of embedding manifests as Win32 resources. You'll also want to read Visual Styles[^] on MSDN.
Another article you may find interesting about making your embedded UserControl scriptable (as well as exposing events), take a look at a very old article of mine on a different site, User Controls for Winodws and the Web[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hello,
I Hope someone can help me with my problem.
I Do the following:
- Create application
- Put combobox on main-form
- Add values in combo-box collections
When I run the application the items in de combobox are not visible. When I click on an invisible item, the value appears in the combobox, so the items are present.
When I copy the application to any other pc and run it, it all works fine, there is no problem.
When I build the application on the other pc and run it on mine, it all works fine too.
My colors are correct (background and textcolor are definitly not the same color).
Help!!!
|
|
|
|
|