|
Hi,
when i have to use and when i shld not use generics ?
Thanks in advance
Azeez.
|
|
|
|
|
|
A quick rule of thumb - if your application is doing boxing/unboxing and there are common features on a class, possibly based off an interface, then you should really consider using generics.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
Wherever you can - Generics is a very broad subject and it has many applications. It allows your code to work with more than one type at runtime with type safety. If you use a generic List instead of an object array, there's no boxing/unboxing happening at runtime which actually improves performance by orders of magnitude. And there are millions of advantages. I would suggest that you go over the articles on the Internet to learn generics. Initially it may seems to be a complicated technology, but once you start appreciating its purpose, thing will be easy for you.
Essential C# 2.0: Chapter 11: Generics[^]
|
|
|
|
|
Hello.
I have a Datagrid which is bound to a dataset. One of the columns I have changed to ComboBoxColumn. This is bound to a column in the dataset. I read that you can change a combobox dropdown style to dropdown in order to make it editable. I can do this with a normal combobox but I can't work out how to do it with a combobox within a datagridview.
What I am trying to achieve is having a combobox that is editable, meaning that you can type something in the box that isn't in the bound list. I am wanting it to also autofill if what is typed matches what is in the bound list. If it is not in the bound list I am wanting to be able to add to the list what was typed in. (add a new row to the dataset).
So basically a field that you can choose from a list or type in your own. This of course is bound to a dataset which in turn will add to the underlying table in the database.
I am using Visual Studio 2008
|
|
|
|
|
Hi,
I'm writing a Windows Forms application in C# and my design view is now only displaying HTML. Is this an alternative view for the form design and if so, how do I revert back? Have I managed to set some flag I shouldn't have?
|
|
|
|
|
My guess is that you are seeing XAML and not HTML, which would indicate you are creating a WPF windows application perhaps? Try choosing a non-WPF windows forms project.
|
|
|
|
|
There's no HTML for Windows Forms application, the design view is constructed from the designer generated C# code in the .designer.cs file. Are you referring to WPF application ? If that is the case, you are seeing XAML and not HTML.
|
|
|
|
|
Yea i got that too once in a while - basically due to an error in the code. What you could do was to close the form, compile the application and the open the form again. That works for me.. sometimes. Other option is to go into the designer mode and find the reason to the error - most often for me is that there is a reference to an image that is removed and is still referenced in that specific form or like.
/Ronni
|
|
|
|
|
I have a Windows app and need to display large amounts of capture data in real-time. The .net listview control's virtual mode works, but each time I add a new item the whole control repaints. Any code out there that will do the trick. Thanks
|
|
|
|
|
|
I've tried this. It dosen't help when the ListView is in VirtualMode. Thanks
|
|
|
|
|
if you want the new items to become visible right away, then the LV (or whatever other control you use) has to repaint itself, what else could it do?
if you don't want immediate display, you could collect new items outside the control, then add them to the control once either one of the following occurs: your new items in hand exceed a certain number, or some timeout has elapsed. The list-oriented controls have an AddRange method to do that efficiently.
I know of no control that would do all that automatically; of course you can derive your own from any of the existing list-oriented controls.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
I want immediate displaying of the items, but don't want the control to repaint the whole view each time a VirtualItem is added. Thanks
|
|
|
|
|
so in other Word, you want to add an item, without losing viewing position (Scroll bar).
Have you tried Binding data source?
|
|
|
|
|
Not really. Think of this app as a protocol analyzer. As data is read it appears as a listview item. The current item is visible. I can make this work with the listview in non-virtualmode, but due to the fact that there is a large number of items being added to the listview, performance starts to go downhill fast. Putting the listview in virtualmode allows the listview to only maintain items within view. This also works fine if your adding all the items at once. In this case the listview calls me only when it needs to display an item during scrolling etc. The problem is when I change the VirtualCount to indicate that a new item is available the listview repaints the whole view. So what I get is a constant repainting of the view while new items are being added.
|
|
|
|
|
thanks for explanation. Now I Clearly know what it does.
Have you tried enabling DoubleBuffer?
If that won't work, then you need to override event: OnPaint and you handle it
|
|
|
|
|
I don't see where to enable DoubleBuffer.
|
|
|
|
|
|
This did the trick. My listview is flikker free.
Thanks
|
|
|
|
|
hi dudes,i have an application written by c#,visual studio 2008,my database file is an access db.i have a maskedtextbox that user enters the date,(short date as 1388/02/15-it's persian date),i parse the string to date,and i insert some data into my database,icluding the parsed date.furthermore i want to update or insert records which their date is between that date and a month later.so after parsing the entered string into date,i seperate its year,month and day, so i can add a day in farsi calender format.everything's going right until in the loop i reach the date which is '1388/02/30', i get an exception which says 'string was not recognized as a valid dattime'.where's the problem? why all the days has not any problem while that specific day has the problem? i traced the application and i'm sure the string that is being parsed while the exception raises,is 1388/02/30.
more desc:in persian (farsi) calender,6 first monthes of the year has 31 days,and the 6 last monthes has 30 days.
|
|
|
|
|
Sounds like it's not using the Farsi calendar...
In our calendar (Whatever you call it), 1388/02/30 would parse to February 30th, 1388... Since 1388 is a leap year, that month has 29 days.
Make sure you're using the right DateTimeFormatInfo in the parsing function.
|
|
|
|
|
I think these might help:
Persian Calendar
[^]
Persian Calendar Members[^]
The references refer to a type that is specifically designed for handling Persian dates as the month lengths are incompatable with Gregorian dates (ie xxxx/02/31 is valid). You will most probably need to convert to a standard DateTime (there is a ToDateTime method) when saving to database, otherwise you are in for a world of pain trying to get it to work.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
How to provide checking of only one menu item from some number of menu items grouped together? That is once you checked one item, previous one should uncheck itself.
Without coding that behaviour?
Чесноков
|
|
|
|