zoukankan      html  css  js  c++  java
  • .Net语言 APP开发平台——Smobiler学习日志:如何快速在手机上实现ContextMenu

    最前面的话:Smobiler是一个在VS环境中使用.Net语言来开发APP的开发平台,也许比Xamarin更方便

    样式一

    一、目标样式

    smobiler

    我们要实现上图中的效果,需要如下的操作:

    1.从工具栏上的”Smobiler Components”拖动一个GridView控件和一个ContextMenu控件到窗体界面上

    smobiler

    2.修改GridView控件的属性

    a.load事件代码

    VB:
        Private Sub TestContextMenu_Load(sender As Object, e As EventArgs)Handles MyBase.Load
            Dim matTable As New DataTable
            matTable.Columns.Add("MAT_IMG", GetType(String))
            matTable.Columns.Add("MAT_DESC1", GetType(String))
            matTable.Rows.Add()
            matTable.Rows(0)("MAT_IMG") = "log"
            matTable.Rows(0)("MAT_DESC1") = "COMS"
            matTable.Rows.Add()
            matTable.Rows(1)("MAT_IMG") = "logon"
            matTable.Rows(1)("MAT_DESC1") = "smobiler"       
            Me.gridView1.DataSource = matTable
            Me.gridView1.DataBind()
            
        End Sub
    C#:
        private void TestContextMenu_Load(object sender, EventArgs e)
        {
            DataTable matTable = new DataTable();
            matTable.Columns.Add("MAT_IMG", typeof(string));
            matTable.Columns.Add("MAT_DESC1", typeof(string));
            matTable.Rows.Add();
            matTable.Rows[0]["MAT_IMG"] = "log";
            matTable.Rows[0]["MAT_DESC1"] = "COMS";
            matTable.Rows.Add();
            matTable.Rows[1]["MAT_IMG"] = "logon";
            matTable.Rows[1]["MAT_DESC1"] = "smobiler";
            this.gridView1.DataSource = matTable;
            this.gridView1.DataBind();
        }

    b.CellLongClick事件代码

    VB:
       Private Sub gridView1_CellLongClick(sender As Object, e As GridViewCellEventArgs) Handles gridView1.CellLongClick
           contextMenu1.Show()
       End Sub
    C#:
       private void gridView1_CellLongClick(object sender, GridViewCellEventArgs e)
       {
           contextMenu1.Show();
       }

    注:调用ContextMenu控件

    c.Layout属性

    新创建MobileForm项,并命名为MessageShow,并拖入一个Label控件和一个Image控件,如图1;

    Label1的DataMember属性(绑定需要显示的列),如图2;

    contextmenu的Layout属性,绑定新建的窗体MessageShow1,如图3;

    smobiler smobiler smobiler
    图1 图2 图3

    3.修改ContextMenu控件的属性

    a.BackColor属性

    获取或设置ContextMenuItem的背景,默认设置为“White”,如图1;

    b.Items属性

    打开集合编辑器,并点击"添加",ForeColor属性(文本颜色),Icon属性(Item的Icon图像资源),Text属性(Item的文本),Value属性(内部值,不在界面上显示),如图2、图3;

    c.ShowPosition属性

    设置ContextMenu显示的位置,默认设置为“LastTouch”,表示显示在最后触摸的地方,如图4;

    若将该属性设置为“CenterScreen”,则表示显示在屏幕中心。

    BackColor属性 Items属性 Items属性 ShowPosition属性
    图1 图2 图3 图4

    二、手机效果显示

    smobiler smobiler

  • 相关阅读:
    hdu 1251 字典树模板题 ---多串 查找单词出现次数
    一个极其简洁的Python网页抓取程序,自己主动从雅虎財经抓取股票数据
    JSONObject与JSONArray的使用
    关于DPM(Deformable Part Model)算法中模型结构的解释
    fullcalendar日历控件知识点集合
    android--自己定义ProgressDialog显示位置(其他Dialog子类都能够设置)
    最简单的Java框架
    java final keyword
    IBinder对象在进程间传递的形式(一)
    windows的定时任务设置
  • 原文地址:https://www.cnblogs.com/amanda112/p/6224973.html
Copyright © 2011-2022 走看看