?
Solved

Creating a custom grid

Posted on 2004-09-14
3
Medium Priority
?
187 Views
Last Modified: 2010-04-15
Hi,

I am quite new to C# and need a bit of help :)

I need to create a control that simulates a grid  (it doesn't have to be a grid!) with 3 fields.
Field 1: Should hold a 'custom control', for which events can be fired. (I need the click event)
Field 2: Should hold a fixed value, that can't be changed.
Field 3: Should hold a text value, that can be changed. (Renamed)

I'm a bit stuck at this stage (don't really know where to start), and any help would be appreciated.

Thanx,
AA
0
Comment
Question by:april_angel
2 Comments
 
LVL 6

Accepted Solution

by:
Svetlin_Panayotov earned 1500 total points
ID: 12055697
CodeProject - http://www.codeproject.com/cs/miscctrl/csharpgridcontrol.asp 
I found this really cool grid - and have been using it for some time.I'm not quiet sure if it'll help - the source is a bit complicated.
0
 

Author Comment

by:april_angel
ID: 12245885
Hi,

Apologies for not answering the question. I had a look at Svetlin comment, and it does not really solved my problem.
I have found the answer though:
All I had to do was create all my controls progammatically and place it into a container (panel). I didn't know that by creating the controls like this I would be able to enable the events, and the fact that control arrays are not available in C# didn't make it easier, either.   Below follows an excerpt of the code I've used. What the application code does it runs a loop that calls the procedure below and keeps adding the controls to the containing panel.

private void CreateGridEntry(int Index, string DisplayText)
{
      //Declare and Initialise
      Button btnLayerValueDisplayColor = new Button();
      Label lblLayerValueDisplayName = new Label();                  
      TextBox txtLayerValueEntry = new TextBox();      


      //Button
      btnLayerValueDisplayColor.Name = "btnValueDisplayName_" + Index.ToString();
      btnLayerValueDisplayColor.Click += new System.EventHandler(this.ChangeSymbolEvent);
      btnLayerValueDisplayColor.Height = 24;
      btnLayerValueDisplayColor.Top = (btnLayerValueDisplayColor.Height + 6)* Index
      btnLayerValueDisplayColor.Left = 8 ;
      btnLayerValueDisplayColor.Width = 24;                  
      btnLayerValueDisplayColor.Tag =Index.ToString();
      btnLayerValueDisplayColor.Image = Image.FromFile(Application.StartupPath + @"\Images\Painter.bmp");
      pnlSymbolSet.Controls.Add(btnLayerValueDisplayColor);
      
      //Label
      lblLayerValueDisplayName.Name = "lblValueDisplayName_" + Index.ToString();
      lblLayerValueDisplayName.Top = btnLayerValueDisplayColor.Top;
      lblLayerValueDisplayName.Left = btnLayerValueDisplayColor.Left + btnLayerValueDisplayColor.Width;
      lblLayerValueDisplayName.Text =  DisplayText;
      lblLayerValueDisplayName.Width = 190;
      lblLayerValueDisplayName.Height = btnLayerValueDisplayColor.Height;
      lblLayerValueDisplayName.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
      pnlSymbolSet.Controls.Add(lblLayerValueDisplayName);
}

Again, I apologise for not replying sooner.

Thanx in any case,
AA
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question