|
I have one listview which is owner drawn. I have to change the grid line color. I tried this by making GridLines = false for listview and Draw the gridlines programatically. But if there are 100 items its flickering and a lot of painting issues
Sibi
|
|
|
|
|
Where do you put the painting code?
Paste your code, or it's hard to resolve it.
---------------------------------
Believe what you saw!
|
|
|
|
|
///
///
///
/// <param name="sender" />
/// <param name="e" />
private void TreeListView_DrawItem( object sender, DrawListViewItemEventArgs e )
{
Graphics g = e.Graphics;
TreeListViewItem item = ( TreeListViewItem )e.Item;
item.UpdateBounds();
this.DrawExpandMarker( g, item );
this.DrawCheckBox( g, item );
StringFormat sf = new StringFormat();
sf.LineAlignment = StringAlignment.Center;
sf.FormatFlags = StringFormatFlags.NoWrap;
SolidBrush foreBrush = new SolidBrush( this.ForeColor );
if( this.changeSelectionForeColor == true )
{
foreBrush = new SolidBrush( item.ForeColor );
}
SolidBrush fillBrush = new SolidBrush( item.BackColor );
Rectangle fillRect = e.Bounds;
fillRect.X = item.TextBounds.X;
fillRect.Width -= fillRect.X;
fillRect.Height -= 1;
if( item.Selected == true && item.ReadOnly == false && item.IsDummy == false )
{
selectedItem = item;
item.IsInvalidated = false;
foreBrush = new SolidBrush( SystemColors.HighlightText );
if( this.changeSelectionForeColor == true )
{
foreBrush = new SolidBrush( item.ForeColor );
}
fillBrush = new SolidBrush( SystemColors.Highlight );
}
g.FillRectangle( fillBrush, fillRect );
string text = this.GetAdjustedString( g, e.Item.Text, item.TextBounds, this.Font );
if( item.ReadOnly == false )
{
g.DrawString( text, this.Font, foreBrush, item.TextBounds, sf );
}
if( item.IsButtonNeeded == true )
{
SolidBrush buttonBrush = new SolidBrush( this.Parent.BackColor );
Rectangle buttonRect = item.ButtonBounds;
g.FillRectangle( buttonBrush, buttonRect );
Border3DStyle border = item.IsButtonPressed ? Border3DStyle.Adjust : Border3DStyle.RaisedInner;
ControlPaint.DrawBorder3D( g, buttonRect, border );
sf.Alignment = StringAlignment.Center;
this.Draw3DText( g, buttonRect, item.ButtonText, sf, item.IsButtonPressed );
buttonBrush.Dispose();
}
if( item.ReadOnly == true )
{
g.DrawString( text, this.Font, Brushes.Gray, item.TextBounds, sf );
Rectangle shadowRect = e.Bounds;
shadowRect.Width -= item.SymbolBounds.X - shadowRect.X;
shadowRect.X = item.SymbolBounds.X;
SolidBrush shadowBrush = new SolidBrush( Color.FromArgb( 60, Color.Gray ) );
g.FillRectangle( shadowBrush, shadowRect );
shadowBrush.Dispose();
}
sf.Dispose();
if( this.gridLines == true )
{
this.DrawGridLine( g, item );
}
fillBrush.Dispose();
foreBrush.Dispose();
}
///
///
///
/// <param name="g" />
private void DrawGridLine( Graphics g,TreeListViewItem item )
{
int dispHeight = this.DisplayRectangle.Height;
int itemHieght = item.TextBounds.Height;
int itemCount = ( dispHeight / itemHieght );
int yPos = itemHieght;
int width = this.Width;
Pen pen = new Pen( this.gridLineColor );
for( int index = 0; index < itemCount; ++index )
{
g.DrawLine(pen, new Point(0, yPos), new Point(width, yPos));
yPos += itemHieght;
}
if( this.Columns.Count == 0 )
{
return;
}
int xPos = 0;
ColumnHeader column = this.Columns[ 0 ];
xPos = column.Width;
for( int colIndex = 1; colIndex < this.Columns.Count; ++colIndex )
{
column = this.Columns[ colIndex ];
g.DrawLine(pen, new Point(xPos, 0), new Point(xPos, this.Height));
xPos += column.Width;
}
pen.Dispose();
}
|
|
|
|
|
Can anyone please tell what is the substitute of #define directive in C#, actually i want to write equivalent following code of C++ in C# .
#define TOTALMONTHS 12<br />
CString strMonths[TOTALMONTHS];
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
|
|
|
|
|
I believe this can be done, but why ? It's nasty in C++, and it's nasty in C#.
const int TOTALMONTHS = 12;
string[] strMonths = new string[TOTALMONTHS];
Why on earth would you anticipate ever changing how many months are in a year ? Or is it a co-incidence that total months = 12 ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: const int TOTALMONTHS = 12;
string[] strMonths = new string[TOTALMONTHS];
Thanks for the answer.
Christian Graus wrote: It's nasty in C++, and it's nasty in C#.
Why it's nasty?
Christian Graus wrote: Why on earth would you anticipate ever changing how many months are in a year ? Or is it a co-incidence that total months = 12 ?
Can you please elaborate it more; I think that there are 12 months in an year that's why i took that particular example.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
|
|
|
|
|
Mushq wrote: Why it's nasty?
Because the preprocessor runs before the compiler, and it makes for code that's impossible to debug. Defining a value with it, rather than a const int, makes no sense. It's a hangover from C, and Bjarne Stroustrup, the person who invented C++, also recommends not using it.
Mushq wrote: Can you please elaborate it more
You factor things into variables, because you expect to change them. The number of months in a year, is something you can safely hard code.
Mushq wrote: Thanks for the answer.
You're welcome. It's the #define I have a problem with, I'd write this in C++ using const int instead of #define also, in that sense, I've not given you a direct answer, #define is different, for the reasons I stated. The end result is the same, and the code is better IMO.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
C# already contains the directive #define
why are u looking for its substitute??
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
The #define directive in C# doesn't do the same as in C++. A #define in C++ defines a macro, while in C# it defines a precompiler symbol.
---
single minded; short sighted; long gone;
|
|
|
|
|
didnt have that in mind earlier
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
There is no substitute for the C++ #define in C#. Thankfully there is no precompiler macros in C#.
Your code can be written using a constant in C# (as already has been suggested). It's not the same as a C++ #define, as it's not a macro, but in your special case the result is exactly the same. The value of the constant will be replaced at compile time.
---
single minded; short sighted; long gone;
|
|
|
|
|
Use a constant. Or consider using an enum of the months;
enum Month { January=1 ... } ;
Month monty = (Month) System.DateTime.Today.Month ;
System.Console.WriteLine ( Monty.ToString() ) ;
But if you really want to, you can use the C preprocessor with a C# source file or any text file you happen to want to mess with.
|
|
|
|
|
Is there any way when on calling the method UndoCheckout of IVSSItem interface, it should not replace the file copy at hard disk with the master copy of source safe.
I hope i have conveyed my question.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
|
|
|
|
|
Hi.,
I want to get a record from MS Access where a datetime field is equal to a C# DateTime type's ToShortDateString(), for example,
DateTime myTime = DateTime.Now;
string query = "SELECT * FROM myTable WHERE [date] = '" + myTime.ToShortDateString() + "'";
Now, is it correct syntax or do I need any Convert function in JET SQL ?
Is it correct to compare with C# DateTime's ToShortDateString() formatted value with JET SQL Date type field ?
I want to compare only the Date part, no Time stamp. I want to get all records for the same date I query. But if it compares also with the time part, then In fact I will not get any record in return because it is not useful to get a records for a particular second.
Would you please help me.
Thanks.
|
|
|
|
|
Try this:
"SELECT * FROM myTable WHERE DateValue(date) = '" + myTime.ToShortDateString() + "'";
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
Dear Parwej
Thanks a lot for your help. Now it is working.
|
|
|
|
|
Hi all,
I am a new user in c# infragistic.
In c# windows application, i use ultrawintree in outlook express view style.
Now i'm trying to add new root in running time, but it don't change anything.
But if i change the view style in default style, it will add new root.
Can any one help me?
Or can any one give me the tutorial?
Many-many thanks..
|
|
|
|
|
Hi,
Many of the folks in this forum don't work with the Infragistics controls. If you don't get an answer to your question here, I suggest you post in the Infragistics forums, or look over their examples and documentation.
|
|
|
|
|
Judah Himango wrote: Many of the folks in this forum don't work with the Infragistics controls
...and with good reasons, too! They might look great, but they are horrible to program against.
|
|
|
|
|
Is that right? Interesting. I've never worked with them before.
|
|
|
|
|
Hi
the title said it.
I want to read a barcode from a USB barcode reader
into a TextBox.
how can I do that by Code?
|
|
|
|
|
I expect a hardware device to come with a driver and a manual?
if not, Google the make and model.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Most bar code readers come with a driver which can be set to emit text into the control that has the focus.
If there's no driver, you can't do anything with it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
The barcode readers take the input just the same way as you give the input from a keyboard or a mouse. So if u have the drivers installed properly, I think it should be much trouble for u
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
When barcode readers read a codebar send an input as keyboard. Generally send the barcode and a final return. But it may very or be configured.
Metrologic codebar readers work in this manner
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|