|
Drawing a circle: Graphics.DrawElipse[^] - you can get the graphics context from the Paint event PaintEventArgs.Graphics[^] property.
Double Buffering: see the Control.DoubleBuffered[^] property for the simple way, or Double Buffered Graphics[^] if you need something more complex.
You could have found all this very easily by using Google...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
I'd do something that looked a little bit like this:
public abstract class Shape
{
protected Rectangle { get; private set; }
public Shape(Rectangle rectangle)
{
SetBounds(rectangle);
}
public void SetBounds(Rectangle rectangle)
{
this.Rectangle = rectangle;
}
public abstract void Draw();
}
public class Circle : Shape
{
public void Draw()
{
}
} That's the hard bit done - I've left the easy bit for you to fill in.
|
|
|
|
|
Hi,
How can I define a class that is enable to add properties dynamically to it?
Best wishes
|
|
|
|
|
There could be someways to do this.
Using an indexed property is an easy way to do this.
Generics provides a way to do this as well[^].
Reflection could also be used for this too.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
The easy way to do this is to add a class that inherits from DynamicObject[^].
|
|
|
|
|
I am trying to develop an application with list view having CheckBoxes and Multiple Selection property as TRUE.
Single Selection works perfectly. But when I try Multiple selection, check box of all the currently selected rows get changed on every selection (and sets to not of the check value of the new selection)
Am I missing any event that I need to handle???
Please help me guys!!!
Thanks in advance...
Although I haven't handle any event, I am still giving the code (I think it'll be irrelevant)
<br />
<br />
this.listView.CheckBoxes = true;<br />
this.listView.FullRowSelect = true;<br />
this.listView.HideSelection = false;<br />
this.listView.UseCompatibleStateImageBehavior = false;<br />
this.listView.View = System.Windows.Forms.View.Details;<br />
<br />
<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
listView.Columns.Add("One", 100, HorizontalAlignment.Left);<br />
listView.Columns.Add("Two", 100, HorizontalAlignment.Left);<br />
listView.Columns.Add("Three", 100, HorizontalAlignment.Left);<br />
listView.Columns.Add("Four", 100, HorizontalAlignment.Left);<br />
<br />
for(int i = 0; i < 50; i++)<br />
{<br />
ListViewItem item = new ListViewItem();<br />
item.Checked = true;<br />
item.SubItems.Add("Garbage1");<br />
item.SubItems.Add("Garbage2");<br />
item.SubItems.Add("Garbage3");<br />
listView.Items.Add(item);<br />
}<br />
}<br />
}<br />
IMP:- This is happening only when I am clicking column other than the first one for selection...
modified on Saturday, July 9, 2011 5:39 AM
|
|
|
|
|
|
Thanx for the reply...
No Multiple Selection property is TRUE...
It hardly takes 5 minutes to make this sample...
Just Try it... I think this is the default behavior...
Am I missing any event that I need to handle???
Please help me... Getting stuck on such a puny issue :-|
Full points for anybody who helps... (Silly Bargain )
|
|
|
|
|
This is the correct behaviour. Selecting an item should not change it's checked state. If it did then the check box would be useless as it would only be a reflection of the selected state which is already indicated by the focus rectangle.
To get the behaviour you desire, handle the ListView 's Click event:
private void listView_MouseClick(object sender, MouseEventArgs e)
{
foreach (ListViewItem item in listView.Items)
item.Checked = item.Selected;
}
By the way, the inline code widget is for code written inline like this . The code block widget is for
blocks of code
like this
|
|
|
|
|
Thanks for replying. I know that it is the default behavior of list view with Check box but I need to change that.
The solution you gave fails if I select some unchecked Item...
|
|
|
|
|
I guess Multiple Selection Property and Check Box property are the for same purpose. To eliminate multiple selection by CTRL Key, we can also use CheckBoxes property. Using both the properties simultaneously conflicts behaviorally. It was my clients requirement to ave Enable /Disable feature in the list itself. Indeed, it wasn't the best way to design by using checked property of ListView for any other purpose. After a long discussion with my team members, we have come to a conclusion that it is better to eliminate Multiple Selection feature from the product. :-|
Although, I have a possible solution- Store the state of all the items just before every click and re-apply it after the click.
But this might create trouble only if no. of items exceed a few thousand. Anyways, I am still open for better (optimized) solution.
Thanks everybody...
|
|
|
|
|
Hi,
In my datagridview, if I click on a cell, the entire cell is getting selected. Instead, I'm trying to select the value in the cell. Can you guide me to get this.
Thanks and Regards,
Lalitha.
|
|
|
|
|
|
0bx wrote: In the designview
Where did the OP mention anything about design view?
0bx wrote: Changing the values in the gridview
The OP asked for highlighting, not editing.
Please read the question thoroughly before commenting
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
MSDN?...[^]
Rhys
"I'd rather die on my feet than live on my knees"
|
|
|
|
|
Hello,
you can try handling the events or CellClick CellContentClick and manage your DataGridView EditMode property as follows.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;
dataGridView1.BeginEdit(true);
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;
dataGridView1.BeginEdit(true);
}
Then you have to manage one of these two events, the one that best suits your needs.
Bye
Carmelo La Monica
|
|
|
|
|
Hi,
I have a datatable from which i am exporting the results to Excel file.The exporting happens perfectly....But web page is not getting loaded completely.Its because of the Response.End();.It terminates the execution of the page further.
Because I have some other code after Response.End(); to get executed and needs to be displayed in the page.Is there a way to get the complete execution of the page.I am struck with this problem for while now..........Any help is appreciated.
DataTable dtMemberList = LinqToDatatable.LinqToDataTable(MembersList);
string attachment = "attachment; filename=Search.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
Response.Write("\n");
Response.Write("Search Results");
Response.Write("\n");
string tab = "";
Response.Write(tab + "Member ID");
tab = "\t";
Response.Write(tab + "Memberdoc Received Date");
tab = "\t";
Response.Write(tab + "Memberdoc Import Date");
tab = "\t";
Response.Write(tab + "Memberdoc Status");
tab = "\t";
Response.Write(tab + "Memberdoc Type");
Response.Write("\n");
int i;
foreach (DataRow dr in dtMemberList.Rows)
{
tab = "";
for (i = 0; i < dtMemberList.Columns.Count; i++)
{
Response.Write(tab + dr[i].ToString());
tab = "\t";
}
Response.Write("\n");
}
Response.End();
|
|
|
|
|
DON'T cross post. Read the forum guidelines. Choose one forum and use it.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
What he said, and learn to use the pre tags.
|
|
|
|
|
How connecting to a database (MS SQL) by the c# code and not by the form guide?
I hope you manage to understand the question ...
greetings,
Dread
|
|
|
|
|
Using a <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx">SqlConnection</a>[<a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx" target="_blank" title="New Window">^</a>] object. There's an example at the bottom of the page.
Bastard Programmer from Hell
|
|
|
|
|
You need to use ADO.Net directly in your code.
Setup a connection and then execute query using a command.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
|
|