Solved

Creating a custom grid

Posted on 2004-09-14
3
179 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
3 Comments
 
LVL 6

Accepted Solution

by:
Svetlin_Panayotov earned 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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