المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Error please help



C# Programming
11-07-2011, 04:41 PM
Hai,

Please take a look my code
using System;using System.Collections.Generic;using System.ComponentModel;using System.Runtime.InteropServices;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms; namespace Combo{ public class Combo //:IDisposable { private System.Windows.Forms.ComboBox li = new System.Windows.Forms.ComboBox(); //object public event EventHandler SelectedIndexChanged; private object[] eventObject; public void Addselect(Control FormName, string name, int top, int left, int width, int height, string Text) { li.Top = top; li.Left = left; li.Width = width; li.Height = height; li.Name = name; li.FlatStyle = FlatStyle.Flat; li.Text = Text; li.IntegralHeight = false; li.MaxDropDownItems = 5; li.DropDownStyle = ComboBoxStyle.DropDown; li.Size = new System.Drawing.Size(136, 81); li.BackColor = System.Drawing.Color.DarkGray; FormName.Controls.Add(li); eventObject = new object[] { this, "SelectedIndexChanged" }; li.SelectedIndexChanged += new EventHandler(li_SelectedIndexChanged); } private void li_SelectedIndexChanged(object sender, EventArgs e) { if (SelectedIndexChanged != null) //You must test this. { SelectedIndexChanged(eventObject, null); } } public bool Enabled { get { return li.Enabled; } set { li.Enabled = value; } } public bool Visible { get { return li.Visible; } set { li.Visible = value; } } public void Addtocombobox(string [] arguments ) { li.Items.AddRange(arguments); } public int sindex() { int index; index = li.SelectedIndex; return index; }} }
The problem is

public int sindex() { int index; index = li.SelectedIndex; return index; }
when i try to return the selected index of combobox i got error here please hep me to do fix this error

This is my error please take a look this

Error 1 Since 'Combo.Combo.sindex()' returns void, a return keyword must not be followed by an object expression F:\SelectboxLibrary\SelectboxLibrary\Class1.cs 65 13 SelectboxLibrary i dont know what is the error

Anyone Please help me?
Arunkumar.T