|
Hi,
I'm doing research on application similar to VNC Viewer or build-in Windows Remote Desktop Connection. Can anybody help mi with some basic ideas, links, what to aware of etc... I will be a .NET 2.0 Windows application (run on both comuters).
Thank you very much.
|
|
|
|
|
When i inser a break point and debug a c# programme i m unable to change the code in this mode(Debug Mode). I remeber previously i can change code in c# APplication.Has any body idea what reason may be ????? Why it is not allowing to change code while debugging.Now it gives follwing message on change of code "Changes are not allowed when debugger has been attached to an already running process or the code being debugged is optimized"
|
|
|
|
|
hi,
As far as i know you can make changes to the code during runtime only in a web application. You cannot do it in a windows application.
Thanks
Regards
Anuradha
|
|
|
|
|
That's strange, edit and continue only ever works for me in a winforms application. It never works for me in web apps.
You do need to make sure that you have "break all processes when one process breaks" checked (*This may or may not be the exact text)
Russell
|
|
|
|
|
Are you sure that you can't? Even when the execution point is inside the same method where you want change code?
...
But i think that is a dangerous practice... Sometimes when you change code often in debug mode applications behaviour change, or that's my experience. Because you change code, and seems that it don't applies changes... And when you're angry because you don't know where is the problem, you close VS, clean and rebuild your app and all is fine... That's my opinion...
Have you suffered this?
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
Yes I M sure .I have told that i cannot change even within the same method .Dunot know whts happened to this application
|
|
|
|
|
You can, simply enable Edit And Continue as proposed in another post in the project options.
Although it will only work if the process was started by the debugger and not if the debugger is attached to the process.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
Is "Edit and Continue" enabled? (Tools->Options->Debugging->Edit and Continue)
|
|
|
|
|
hi all,
I am using a datagridview to display contents of a xml file. say i have a xml file like this.
<xml version="1.0" encoding="UTF-8">
<maincategory>
<cat1>
<title>Category1</title>
<link>http://www.w3schools.com</link>
<description><img src="http://static.ibnlive.com/pix/sitepix/09_2007/flames_ramsetu90.jpg" >some description</description>
</cat1>
<cat2>
<title>Category2</title>
<link>http://www.ibnlive.com</link>
<description><img src="http://static.ibnlive.com/pix/sitepix/09_2007/rahul_gandhi_white90.jpg"
>some description</description>
</cat2>
</maincategory>
initially i display only the title of the category in the grid.
when the cell is clicked, i display title as well as description. when i click the cell again, only the title should be displayed.
i have managed to do this part.
the following code is for the first time click
if (cell_click_flag[rindex]==false)
{
TextAndImageCell cell = (TextAndImageCell)datagridview1.CurrentCell;
cell.Value = "";
cell.Image = Image.FromFile(Application.StartupPath + "//spacer.gif");
datagridview1.CurrentCell.Value = datagridview1.Rows[rindex].Cells["Description"].Value;
cell.Style.Alignment = DataGridViewContentAlignment.TopLeft;
cell_click_flag[rindex] = true; datagridview1.AutoResizeRow(rindex, DataGridViewAutoSizeRowMode.AllCells);
}
else if (cell_click_flag[rindex] == true)
{
//for the second time click
TextAndImageCell cell = (TextAndImageCell)dat.CurrentCell;
cell.Value = "";
cell.Image = Image.FromFile(Application.StartupPath + "//spacer.gif");
datagridview1.CurrentCell.Value = datagridview1.Rows[rindex].Cells["temp_title"].Value;
cell.Style.Alignment = DataGridViewContentAlignment.TopLeft;
cell_click_flag[rindex] = false; datagridview1.AutoResizeRow(rindex, DataGridViewAutoSizeRowMode.AllCells);
}
but when i again click the cell, only the title is displayed and not the description.i tried debugging, the value contains both title and description but only title is displayed.
I could not understand the problem.
Can anybody suggest me with some ideas?
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
thanks guys. i solved it myself.
For anybody's reference, i included beginedit(true) and endedit() methods to update the cell values.
Thanks again.
Regards
Anuradha
|
|
|
|
|
I have one button and one listbox on same Form.
Inside InitializeComponent()
{
For button1 I have
this.button1.Click += new System.EventHandler(this.Button1Click);
and for listBox1 I have
this.listBox1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ListBoxKeyUp);
}
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
void Button1Click(object sender, EventArgs e)
{
Console.WriteLine("Btn Clicked");
this.listBox1.Focus();
}
void ListBoxKeyUp(Object sender, KeyEventArgs kev)
{
Console.WriteLine("List KeyUp");
// My Code to Handle the Key Up
}
}
On Running the App and Pressing Enter on button1
The Output is
Btn Clicked
List KeyUp
All I actually wanted was to give (in button1's Click Event) the Focus to listbox1 and return. My listbox is actually a playlist and whenver Enter is pressed on it the selected entry starts to play. Only one click (via Keyboard) was made on button1 but listbox1's KeyUp Event also is getting fired.
Please Advice
Thanks...
P.S. The Code Works fine if button1 is clicked via Mouse
|
|
|
|
|
Well, what did you expect ? Here's the sequence:
1 - you press enter down. This clicks the default button. This gives the listbox the focus.
2 - you raise the enter key. The listbox has the focus, and so it fires.
Try handling keydown instead of keyup.
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 )
|
|
|
|
|
Hmm. Right Christian. I think I've got a little confused here. The Results are supporting your view. Now If I handle KeyDown with listbox1 then it allows the user to keep the key pressed and the event will keep firing as long as the Key is down. I dont want that.
What is happening here is that the user is clicking the Button, the focus is shifting to listbox1 and a KeyEvent is being generated on listbox and my key handling code is getting executed. (Total KeyPresses 1)
What I really need is that the user should Press a Push Button (button1) and the Focus be transfered to my listbox1. Now if the User wants she may Press a Key (Enter) again to select an Item in listbox1. (Total Key Presses by user 2)
I think I've explained my problem clearly.
So what may be the proper way to achieve this.
Thanks...
|
|
|
|
|
I think I've found the Way
<br />
void Button1Click(object sender, EventArgs e)<br />
{<br />
Console.WriteLine("Btn Clicked");<br />
Application.DoEvents();<br />
this.listBox1.Focus();<br />
Application.DoEvents();<br />
}<br />
Why??? Goto http://www.thescripts.com/forum/post1334126-2.html
|
|
|
|
|
I don't see how that makes any difference, unless you're now beating a race condition by flushing the event queue.
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 )
|
|
|
|
|
I really dont have much Idea about that too. But my app has started to behave as was desired it to.
<br />
void clickHandler(---)<br />
{<br />
Application.DoEvents();<br />
<br />
<br />
Application.DoEvents();<br />
}
Without the Former Application.DoEvents() my code was unaffected
Similar Issue
Yes I myself am not convinced and will try to find a better solution.
Your Thoughts Please...
Thanks...
|
|
|
|
|
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;
|
|
|
|