|
Hi,All
I am writing Grid Like Control in C#.I am drawing the grid(Rectangles) on control.
i have written a class called CellInfo
class CellInfo
{
int x;
int y;
int width;
int height;
int Data;
Color BackColor;
}
which represents one cell(Rectangle) in the grid.
Now i have Arraylist Cells[Rows],which contains ArrayLists[Columns] of CellInfo objects.
Now i want user should be able to change some properties of CellInfo(e.g. data,BackColor)(one rectangle in Grid)at DesignTime.
Something like Items property in ListView.
How should i declare the property.
If i write the property which returns ArrayList containing CellInfo Objects,it does'nt understand CellInfo!
I hope u understand my Problem!
Thanks
Tushar.
|
|
|
|
|
first of all, vs.net needs the class to have properties otherwise the designer cannot edit it, so the class you have there should look like this.
public class CellInfo
{
private Rectangle m_bounds;
private Color m_clr;
private int m_data;
public Rectangle Bounds
{
get { return this.m_bounds; }
set { this.m_bounds = value; }
}
public Color Color
{
get { return this.m_clr; }
set { this.m_clr = value; }
}
public int Data
{
get { return this.m_data; }
set { this.m_data = value; }
}
}
I also think that if you want the designer to design the objects, you cant use ArrayList, but have to use a strongly typed collection, which for CellInfo would be:
public class CellInfoCollection : System.Collections.CollectionBase
{
public CellInfo this[int index]
{
get { return (CellInfo)this.List[index]; }
set { this.List[index] = value; }
}
public CellInfoCollection()
{
}
public void Add(CellInfo info)
{
this.List.Add(info);
}
} All you need to do is change the CellInfo to any other object type to have it work with that type of object.
Ummm....if you want the designer to work properly with your collections, the property that gives access to the collection needs to have the following attribute:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]<br />
public CellInfoCollection Cells<br />
{<br />
get { return this.m_cells; }<br />
}
Making sure you have the using statement for the System.ComponentModel namespace.
just FYI, if you really want to add proper design-time support, take a look at the System.Windows.Forms.Design.ControlDesigner class
Hope that helps.
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
Hi,
Thanks for replying but i am still confused!
Now i Will return CellsCollection instead of Arraylist.
so there are two classes derived from CollectionBase.
CellsCollection and CellInfoCollection.
CellsCollection is like Collection of Collection(CellInfoCollection representing each row)
public class CellInfoCollection : System.Collections.CollectionBase
{
public CellInfo this[int index]
{
get { return (CellInfo)this.InnerList[index];}
set { this.InnerList[index] = value; }
}
public CellInfoCollection()
{
}
public void Add(CellInfo info)
{
this.InnerList.Add(info);
//this.List.Add(info);
}
}
public class CellsCollection : System.Collections.CollectionBase
{
public CellsCollection this[int index]
{
get { return (CellsCollection)this.InnerList[index];}
set { this.InnerList[index] = value; }
}
public CellsCollection()
{
}
public void Add(CellInfoCollection info)
{
this.InnerList.Add(info);
//this.List.Add(info);
}
}
i populate the values of each cell like :
CellsCollection lst = new CellsCollection();
for(int i= 0;i < m_Rows; i++)
{
lst.Add (new CellInfoCollection());
}
for(int row = 0 ; row < m_Rows; row++)
{
CellInfoCollection innercells = new CellInfoCollection();
for(int col= 0 ;col < m_Columns; col++)
{
innercells.Add(new CellInfo());
}
lst.Add(innercells);
}
and property now looks like:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content),Description("Get/Set Properties of each Cell")]
public CellsCollection CellsInfo
{
get {return this.lst;}
}
But in properties window if i click CellsInfo it shows me collections equal to no. of rows.Inside each collection there is another collection,if i click on that it gives me error
"Forms that are already visible cannot be displayed as modal Dialog. Set the forms visible property to false before calling ShowDialog"
For inner Collection Seperate dialog should popup!
How should i inform him that he should popup seperate dialog!
Thanks in Advance
Tushar.
|
|
|
|
|
i dont quite understand the problem...is it possible for me to look at the project? zip it and email it to me at theeclypse@hotmail.com?
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
Hello,
I want my combo box border look like System.Windows.Forms.BorderStyle.FixedSingle. How to do this.
Thanks in advance,
chito
|
|
|
|
|
Look in the c# controls section here in CP - there's plenty of examples
|
|
|
|
|
Hi,
I have created a control library with one control ( this control has a resx, and it's composed of some standard controls).
If I add that control library, to an application, and then I inherit from that control, I get this error message:
"The Item xxxx.resx does not exist in the project
directory, it may have been moved renamed or deleted"
This means that, I need to import the resource to my application ? Is that a bug from Visual studio ?
Thanks in advance, greetings
Braulio
|
|
|
|
|
test desktop bob
|
|
|
|
|
Hi, all!
Would you like to help me, plz?
Have the folow:
I want to create COM+ component with help c#, so, it will use the external(usual) dll-file(my.dll), where contents some logic (com-objects).
This dll good work in usual application, when add it as reference - all ok.
(a have not source for this dll file)
But when i try to link up it in my developed com+ app., - got folow answer from compiler:
"Assembly generation failed -- Referenced assembly 'name of my.dll' does not have a strong name"
is it have not 'strong name'????
i try the next:
al /out:my.dll "?" /keyfile:my_dll.snk
but it don't want to work... i do not understand want is this "?"
and is it right way to solve this problem? and what i must do in this case?
in any case thx.
|
|
|
|
|
to the printer?
Thanks.
this is my signature for forums quoted from shog*9:
I can't help but feel, somewhere deep within that withered, bitter, scheming person, there is a small child, frightened, looking a way out.
|
|
|
|
|
|
do printing in .net in c# lang?
I have already used crystal report viewer,but it seems can't print on non-standard papers?
Thanks.
this is my signature for forums quoted from shog*9:
I can't help but feel, somewhere deep within that withered, bitter, scheming person, there is a small child, frightened, looking a way out.
|
|
|
|
|
http://msdn.microsoft.com/msdnmag/issues/03/02/PrintinginNET/default.aspx
|
|
|
|
|
print reports in non-standard papers,I find that I must select one kind paper,but I want to print on non-standard printer papers.(I mean not print on one paper,but a pack of papers)?
Thanks.
|
|
|
|
|
iam making my console app a little bit more feature filled.. its working out fine...but my question is how can i change the color of key words (such as echo) i want any text with in these arrows(<text here="">) to be turned to the color red how can i do this within my richtext box field.... i already have keypress event args set up and i can allready tell the program what to do when the word "<echo>" is entered,ect.. but im strugling on how to do this . here is the list of all my commands. Any samples would be great.
RichTextField.Name = UserInput;
echo,cls,copyright,?,help,consolesave,consolehide,consoleshow,consoleclose
jesse M
The Code Project Is Your Friend...
|
|
|
|
|
In C#lang,how to do that?If it's a so simple and easily searchable problems,please don't blame me.Thanks.
.rpt file has a SQL stored procedure query that has 3 params,I want to pass values in program,how to do that?
|
|
|
|
|
From within your form containing the progress bar.
ProgressBarEx pbar = new ProgressBarEx();
pbar.Width = 200;
pbar.Height = 200;
pbar.Location = new Point(0, 0);
Controls.Add(pbar);
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
ALL of carlos's cool controls contain sample applications that show how to use them...
Had me stumped just a bit as well when I first started trying until I realized that his controls don't have designers (don't show up in the tool box) so you have to load them manualy in the code.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
|
|
|
|
|
Hi, I'm new to .NET and I'm writing an application that is using the TabControl , and I'm having trouble finding a method or property that will tell me what specific TabPage was clicked when the TabControl is clicked. In the Click event for the TabControl is it possible to tell what TabPage was clicked? I can't seem to find any property or method that would give that.
Another question. Is there any type of event for the TabControl or TabPage that is similar to the Load event for a Form ? What I'm looking for is an event that would fire the first time a TabPage was clicked and then never again until the program was closed and opened.
Any help is much appreciated.
- monrobot13
|
|
|
|
|
monrobot13 wrote:
I'm having trouble finding a method or property that will tell me what specific TabPage was clicked when the TabControl is clicked. In the Click event for the TabControl is it possible to tell what TabPage was clicked? I can't seem to find any property or method that would give that.
Register the Click events for each tabpage instead all pointing to one delegate. Then in the delegate method do a cast to TabPage for the object sender parameter.
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
First, Thanks for the reply.
Second, This is the approach I would have taken but I using the webbrowser control on the tab and it's set to take up the entire size of the page. I want the webpage to load when the tab is clicked I don't want the user to have to click the actual webbrowser page for it to load.
- monrobot13
|
|
|
|
|
To determine which TabPage is currently selected, look at the TabControl.SelectedIndex property, and to catch when a user selects a different TabPage, subscribe to the TabControl.SelectedIndexChanged event - watching Click events is not the way to do it with the TabControl.
There is no Load type event for a TabPage, but there are a number of ways to do what you're looking for.
Create booleans to flag whether each tab has been "loaded"; e.g.
bool tabPage1Loaded = false;<br />
<br />
void OnSelectedIndexChanged(object s, EventArgs e)<br />
{<br />
if(tabControl.SelectedIndex == 1 && !tabPage1Loaded){<br />
tabPage1Loaded = true;<br />
}<br />
}
Or, if your tab pages are created dynamically and hard-wiring booleans would be impossible or just messy, just create a new class derived from TabPage and add a "Loaded" property to it.
Hope this helps
|
|
|
|
|
Again thanks for the reply.
This sounds like a good approach I just have a question. Is it possible to get a reference to the actual TabPage from the selected index? ie. could I just use it as the index in the tabs collection for the TabControl ?
Thanks again
- monrobot13
|
|
|
|
|
monrobot13 wrote:
. could I just use it as the index in the tabs collection for the TabControl?
Yep, sure can.
|
|
|
|
|
Sounds good.
Thanks again.
- monrobot13
|
|
|
|