Hi, I'm writing an application in c#.net, in which i've created array of control Button. I want to display a menu when user clicks any of the buttons in the array. I was able to create context menu for a single button, but not for the array, as coded below ... public class ButtonArray : System.Collections.CollectionBase { private readonly System.Windows.Forms.Form ContainerControl; public ButtonArray(System.Windows.Forms.Form Cont) { ContainerControl = Cont; } public void AddButton() { //code to create button btButton.MouseDown += new MouseEventHandler(btButton_MouseDown); } public void btButton_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { contextMenuStudInfo = new System.Windows.Forms.ContextMenu(); System.Windows.Forms.MenuItem menuItem1; menuItem1 = new System.Windows.Forms.MenuItem(); System.Windows.Forms.MenuItem menuItem2; menuItem2 = new System.Windows.Forms.MenuItem(); contextMenuStudInfo.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { menuItem1, menuItem2 }); menuItem1.Index = 0; menuItem1.Text = "Mark Present"; menuItem2.Index = 1; menuItem2.Text = "Mark Absent"; this.btButton.ContextMenu = contextMenuStudInfo; } }
how to attach the context menu to each member of button control array? Thanks, Kranti -- modified at 5:31 Wednesday 3rd May, 2006
Kranti1251984
Posts
-
How to attach context menu to array of controls? -
How to retrieve attribute of type Time without time zone from postgreSQL?Hello, I am writing one simple C# .NET application in which I have to use some values retrieved from the database. But when I try to retrieve value of attribute of type Time without time zone it generates following exception {"Index was outside the bounds of the array."} System.Exception {System.IndexOutOfRangeException} This happens only when I try to retrive this type .. for other attribute types, it is working properly. My code is ... //-------------------------------------------------------------- String myQuery = "Select starttime from tblecture"; OdbcCommand myCommand = new System.Data.Odbc.OdbcCommand(myQuery, conn); OdbcDataReader dataReader = myCommand.ExecuteReader(); while(dataReader.Read())//Exception being generated on this line { //code to use database info } //-------------------------------------------------------------- Schema of tblecture table is: Table "public.tblecture" Column | Type | Modifiers -----------------+------------------------+---------------------------- lectureid | integer | not null starttime | time without time zone | Thanks, Regards, Kranti
-
Exception: Array index out of boundsthe complete code is as follows ... //.................................. String connectionString = "Dsn=pgTEducation;database=teducation;server=192.168.0.135;port=5432;uid=divinet;readonly=0;protocol=6.4;fakeoidindex=0;showoidcolumn=0;rowversioning=0;showsystemtables=0;fetch=100;socket=4096;unknownsizes=0;maxvarcharsize=254;maxlongvarcharsize=8190;debug=0;commlog=0;optimizer=1;ksqo=1;usedeclarefetch=0;textaslongvarchar=1;unknownsaslongvarchar=0;boolsaschar=1;parse=0;cancelasfreestmt=0;extrasystableprefixes=dd_;lfconversion=1;updatablecursors=1;disallowpremature=0;trueisminus1=0;bi=0;byteaaslongvarbinary=0;useserversideprepare=0"; OdbcConnection conn = new System.Data.Odbc.OdbcConnection(connectionString); String classStartTime; conn.Open(); String myQuery = "Select starttime from tblecture"; OdbcCommand myCommand = new System.Data.Odbc.OdbcCommand(myQuery, conn); OdbcDataReader dataReader = myCommand.ExecuteReader(); try { while (dataReader.Read()) classStartTime = dataReader.GetTime(0).ToString(); } finally { dataReader.Close(); conn.Close(); } //.................................. thanks, Kranti
-
Exception: Array index out of boundsthe exception generated is "Array index out of bounds"
-
Exception: Array index out of boundseven when i make it as ... //................................................... while (dataReader.Read()) //exception classStartTime = dataReader.GetTime(0).ToString(); //................................................... it generates the exception at the previous line i.e. the line containing "while", before going for this statement Thanks, Kranti
-
Exception: Array index out of boundsHi, I'm writing an application in c#.net and i'm completely new to it. Please refer to the following code in which i'm getting an exception... //..................................................................... String classStartTime; conn.Open(); String myQuery = "Select starttime from tblecture"; OdbcCommand myCommand = new System.Data.Odbc.OdbcCommand(myQuery, conn); OdbcDataReader dataReader = myCommand.ExecuteReader(); try { while (dataReader.Read()) //exception classStartTime = dataReader.GetTime(0).ToString(); } finally { dataReader.Close(); conn.Close(); } //..................................................................... I'm getting this exception for only column named "starttime"; for other fields this code works fine. Is there any other way to read a field of type time from database? Thanks, Kranti -- modified at 4:13 Wednesday 19th April, 2006
-
'System.NullReferenceException'hey, thanks a lot .. this type of initialization worked for me ... testlib::testlibControl *tmp1[] = __gc new testlib::testlibControl*[10]; tmp1[i] = new testlib::testlibControl; tmp1[i]->Location = System::Drawing::Point(x,y); tmp1[i]->Size = System::Drawing::Size(24, 29); Thanks, Kranti
-
File transfer: Client-Server CommunicationHi, I'm new to Visual C++.Net and I'm trying to write a client-server application in which I want to transfer an image file [JPEG/BMP/GIF] from server to client. Right now, I've written a code which just transfers "String" type of data from client to server and vice versa. How should I move ahead with images? Thanks, Kranti
-
'System.NullReferenceException'ok .. i've made required changes as follows but still i'm getting the same exception testlib::testlibControl *tmp1 __gc []; tmp1 = new testlib::testlibControl* __gc [10]; for(int i = 0; i < strength; i++) { tmp1[i]->Location = System::Drawing::Point(x,y); //exception .... ... } Thanks, Kranti
-
'System.NullReferenceException'i've created one DLL (testlib) and i want to use it in my application as an array of its instances ... i'm getting an exception as 'System.NullReferenceException' plz consider the following code .. //------------------------------------------------------------------------- testlib::testlibControl *tmp1 __gc[]; for(int i = 0; i < strength; i++) { tmp1[i] = new testlib::testlibControl; tmp1[i]->Location = System::Drawing::Point(x,y); //exception tmp1[i]->Size = System::Drawing::Size(24, 29); x += 30; this->Controls->Add(tmp1[i]); } //------------------------------------------------------------------------- Why does this code cause exception? Thanks, Kranti
-
is there any function similar to sprintf in C++.Net?Hi, I've to write a query which requires a function similar to "sprintf" in C For e.g. String *query; // in c++.net sprintf(query, "Select * from table_name where number = %d", no); // in C How can this be done in this environment? Thanks, Kranti
-
problem with m_strCursorHi, I've an application which creates HTML files. For that i'm using some database operations, which includes classes such as, CDatabase and CRecordSet etc. I'm getting an exception as "invalid cursor" since m_strCursor is getting set to some file name e.g. "test.html", which the application is creating. I'm not able to trace out, how the variable is getting set. Similarly, m_strFilter, m_strSort, m_strUpdateSQL, m_strRequeryFilter, m_strRequerySort are getting set to the same file name. Thanks, Kranti
-
missing storage-class or type specifiersThe same line with prototype of the function, is creating problems for the variable config of type CConfig. -- modified at 0:02 Tuesday 7th March, 2006
-
missing storage-class or type specifiersI had tried this. But logically, it should not work and it doesn't work. But the problem i've mentioned is not the same one.
-
missing storage-class or type specifiersNo, that's the problem. Even though, correct header file is included, it works fine with CDlg but not with CDump. What should I do?
-
missing storage-class or type specifiersI'm sorry, it is #include "Config.h"
-
missing storage-class or type specifiersHi, I'm getting following errors while creating 3 classes as mentioned below ... //--------------------------- class CConfig { //declarations }; //--------------------------- #include "Config.h" class CDlg { CConfig m_config; //no errors }; //--------------------------- #include "Config.h" class CDump { void MyFun(CConfig config); //errors }; //--------------------------- in class CDump i'm getting some errors as ... error C2146: syntax error : missing ';' before identifier 'config' error C2501: 'CConfig' : missing storage-class or type specifiers error C2501: 'config' : missing storage-class or type specifiers as far as class CDlg is concerned i'm able to declare and use the object of CConfig but why doesn't it work in the other case? Thanks, Kranti -- modified at 23:59 Monday 6th March, 2006
-
use of _ltoahey, it worked! :) Thanks a lot! Kranti
-
use of _ltoawhen I check the values stored in both of the arrays, something like the following is observed ... binEffects[3] = '0' binEffects[2] = '0' binEffects[1] = '' binEffects[0] = '1' and the source array contains ... m_Effects[0] = '0' m_Effects[1] = '0' m_Effects[2] = '0' m_Effects[3] = '1' Even if i use memcmp(), it returns -1 if this example is concerned. Hence, i've a doubt regarding _ltoa function since it sets the values in binEffects. Kranti
-
use of _ltoaHi, I want to compare two character arrays containing binary values. For e.g. if m_Effects array contains 0001, string comparison does not return 0 even if binEffects contains binary equivalent of 1. Even if I do byte by byte comparison same problem occurs. What does _ltoa exactly perform? //--------------------------------------------------------------------- for(int i=0; i <16; i++) { _ltoa(i, binEffects, 2); if(strcmp((char *)binEffects, (char *)m_Effects) == 0) return i; } //--------------------------------------------------------------------- Thanks, Kranti