Solved

Creating a custom grid

Posted on 2004-09-14
3
180 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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

713 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